0% found this document useful (0 votes)
11 views25 pages

Purchase and Sales Management Code

This Visual Basic code defines form controls and database interactions for a purchase order form. It includes subroutines to clear the form, add/edit records, print reports, and validate/format data entry. Database objects like Recordsets are used to retrieve and update purchase records based on the form input.

Uploaded by

Arun Krish
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views25 pages

Purchase and Sales Management Code

This Visual Basic code defines form controls and database interactions for a purchase order form. It includes subroutines to clear the form, add/edit records, print reports, and validate/format data entry. Database objects like Recordsets are used to retrieve and update purchase records based on the form input.

Uploaded by

Arun Krish
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

CODING MAIN FORM

Public REPNO As Integer Dim mTime As Double Dim fso As New FileSystemObject Dim td1 As String Dim td As String Dim !ser As "oole#n Pri$#te Sub bil%t&'(lic)*+ REPNO , Dim bno As .ong bno , /#l*In%ut"o0*1Enter t2e Purc2#se "ill No3 1++ If bno , 4 T2en E0it Sub D#t#En$ironment13(omm#nd5'6rou%ing (Str*bno+ If D#t#En$ironment13rs(omm#nd5'6rou%ing3Record(ount 7, 4 T2en 8sg"o0 1Record not found1 Else D#t#Re%ort-3S2ow End If !nlo#d D#t#En$ironment1 End Sub Pri$#te Sub c '(lic)*+ (ustomer3S2ow End Sub Pri$#te Sub e1'(lic)*+ Em%oy3S2ow End Sub Pri$#te Sub 8DIForm'.o#d*+ On Error 6oTo lErr Dim rs As Recordset If fso3FileE0ists*A%%3P#t2 9 1:m#in3mdb1+ , True T2en ;And fso3FileE0ists*A%%3P#t2 9 1:tr#ns3mdb1+ , True Set dbm , O%enD#t#b#se*A%%3P#t2 9 1:m#in3mdb1+ If dbm Is Not2ing T2en End Else "ee% <44= 144 mess#ge 1Some File #re 8issing> Or (orru%ted>1 !nlo#d Frms%l#s2

!nlo#d 8e End If E0it Sub lErr? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub 8DIForm'Resi@e*+ 8#inForm3St#tus"#r13Aidt2 , 8#inForm3Aidt2 End Sub Pri$#te Sub % '(lic)*+ Prodm#st3S2ow End Sub Pri$#te Sub %&'(lic)*+ ProForm3S2ow End Sub Pri$#te Sub %u '(lic)*+ Purc2#se3S2ow End Sub Pri$#te Sub %u&'(lic)*+ PurRet3S2ow End Sub Pri$#te Sub r '(lic)*+ ;D#t#Re%ort53s2ow End Sub Pri$#te Sub %u< '(lic)*+ REPNO , Dim bno As .ong bno , /#l*In%ut"o0*1Enter t2e Purc2#se Return "ill No3 1++ If bno , 4 T2en E0it Sub D#t#En$ironment13c2#nge'6rou%ing (Str*bno+ If D#t#En$ironment13rs(2#nge'6rou%ing3Record(ount 7, 4 T2en 8sg"o0 1Record not found1 Else P!R(BASERET3S2ow End If !nlo#d D#t#En$ironment1 End Sub

Pri$#te Sub s1'(lic)*+ S#les3S2ow End Sub Pri$#te Sub s<'(lic)*+ S#leRet3S2ow End Sub Pri$#te Sub s-'(lic)*+ Su%%lier3S2ow End Sub Pri$#te Sub s#1'(lic)*+ Stoc)3S2ow End Sub Pri$#te Sub ss&<'(lic)*+ REPNO , Dim bno As .ong bno , /#l*In%ut"o0*1Enter t2e S#les "ill No3 1++ If bno , 4 T2en E0it Sub D#t#En$ironment13(omm#nd-'6rou%ing (Str*bno+ If D#t#En$ironment13rs(omm#nd-'6rou%ing3Record(ount 7, 4 T2en 8sg"o0 1Record not found1 Else SA.E3S2ow End If !nlo#d D#t#En$ironment1 End Sub Pri$#te Sub ss# '(lic)*+ REPNO , Dim bno As .ong bno , /#l*In%ut"o0*1Enter t2e S#les Return "ill No3 1++ If bno , 4 T2en E0it Sub D#t#En$ironment13(omm#nd&'6rou%ing (Str*bno+ If D#t#En$ironment13rs(omm#nd&'6rou%ing3Record(ount 7, 4 T2en 8sg"o0 1Record not found1 Else SA.ESRET3S2ow End If !nlo#d D#t#En$ironment1 End Sub

Pri$#te Sub st%1'(lic)*+ Dim sdb As D#t#b#se Dim srs As Recordset Set sdb , O%enD#t#b#se*A%%3P#t2 C 1:m#in3mdb1+ Dim trs As Recordset Set srs , sdb3O%enRecordset*1select %n#me=sum*Dty+ from stoc) grou% by %n#me 1+ REPNO , If REPNO , T2en D#t#En$ironment13(omm#nd If D#t#En$ironment13rs(omm#nd 3Record(ount 7, 4 T2en 8sg"o0 1Record Not Found1 Else D#t#Re%ort 3S2ow End If End If !nlo#d D#t#En$ironment1 End Sub

PRODUCT MASTER
Dim rs As Recordset Dim l#stte0t As String Dim cm%'edit As "oole#n Dim cm%'delete As "oole#n Dim dn#me As String Pri$#te Sub cle#r'(lic)*+ cle#r1 End Sub Pri$#te Sub (omm#nd1'(lic)*+ dbm3E0ecute 1delete from %rodgr% w2ere gr%n#me , ;1 9 te0t13Te0t 9 1;1 cle#r1 End Sub Pri$#te Sub edit1'(lic)*+ On Error 6oTo .oc#lError cm%'edit , True cm%'delete , F#lse l#stte0t , 1edit1 Fr#me 3/isible , True find#cc te0t13Te0t te0t13SetFocus cm%'edit , True E0it Sub .oc#lError?

8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub Form'.o#d*+ Fr#me 3/isible , F#lse cm%'edit , F#lse cm%'delete , F#lse End Sub Pri$#te Sub s#$e'(lic)*+ If cm%'edit , True T2en Set rs , dbm3O%enRecordset*1select E from %rodgr% w2ere gr%n#me,;1 9 dn#me 9 1;1= dbO%enDyn#set+ rs3Edit rs>gr%n#me , !(#se*te0t13Te0t+ rs>gr%desc , !(#se*Te0t &3Te0t+ rs>cm%id , cm%3c'id rs3!%d#te te0t13SetFocus rs3(lose Dim rs1 As Recordset Set rs , dbm3O%enRecordset*1select E from %roduct1= dbO%enDyn#set+ Do A2ile Not rs3EOF If *rs>6rou%1+ , dn#me T2en rs3Edit rs>6rou%1 , !(#se*te0t13Te0t+ rs3!%d#te End If rs38o$eNe0t .oo% rs3(lose cle#r1 E0it Sub End If Set rs , dbm3O%enRecordset*1select E from %rodgr%1= dbO%enDyn#set+ rs3AddNew rs>gr%n#me , !(#se*te0t13Te0t+ rs>6r%Id , getm#0$#l*1select m#0*6r%Id+ #s $no from %rodgr%1+ rs>gr%desc , !(#se*Te0t &3Te0t+ rs>cm%id , cm%3c'id rs3!%d#te rs3(lose cle#r1

te0t13SetFocus End Sub Pri$#te Sub Te0t1'FeyPress*FeyAscii As Integer+ If FeyAscii , 1& T2en Set rs , dbm3O%enRecordset*1select E from %rodgr% w2ere gr%n#me,;1 9 !(#se*te0t13Te0t+ 9 1;1= dbO%enDyn#set+ If Not rs3EOF T2en mess#ge 1N#me Alre#dy Found1 te0t13Te0t , 11 te0t13SetFocus rs3(lose E0it Sub End If Te0t &3SetFocus End If End Sub Pri$#te Sub .ist1'Dbl(lic)*+ On Error 6oTo .oc#lError Select (#se l#stte0t (#se 1edit1 te0t13Te0t , .[Link]*.ist13.istInde0+ dn#me , te0t13Te0t Set rs , dbm3O%enRecordset*1select E from %rodgr% ABERE gr%n#me ,;1 9 te0t13Te0t 9 1;1= dbO%enDyn#set+ Ait2 rs Te0t &3Te0t , >gr%desc

End Ait2 Fr#me 3/isible , F#lse rs3(lose End Select E0it Sub .oc#lError? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub .ist1'Fey!%*Fey(ode As Integer= S2ift As Integer+

On Error 6oTo .oc#lError Select (#se Fey(ode (#se G= 5 Select (#se l#stte0t (#se 1edit1 te0t13SetFocus End Select (#se 1& .ist1'Dbl(lic) End Select E0it Sub .oc#lError? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub find#cc*findte0t As String+ On Error 6oTo .oc#lError Dim rs< As Recordset Dim mlogstr< As String .ist13cle#r

Set rs< , dbm3O%enRecordset*1select gr%n#me from %rodgr% w2ere gr%n#me li)e1 9 1;1 9 findte0t 9 1E;1= dbO%enDyn#set+

Do A2ile Not rs<3EOF .ist13AddItem !(#se*rs<>gr%n#me+ rs<38o$eNe0t .oo% rs<3(lose If .[Link](ount 7H 4 T2en .ist13.istInde0 , 4 End If E0it Sub .oc#lError? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub

Pri$#te Sub cle#r1*+ te0t13Te0t , 11 Te0t &3Te0t , 11 Fr#me 3/isible , F#lse cm%'edit , F#lse cm%'delete , F#lse End Sub Pri$#te Sub Te0t &'FeyPress*FeyAscii As Integer+ If FeyAscii , 1& T2en s#$e3SetFocus End If End Sub

PURCHASE FORM
Dim rs As Recordset Dim l#stte0t As String Dim dn#me As String Dim cm%'edit As "oole#n Dim cm%'delete As "oole#n Pri$#te Sub (omm#nd1'(lic)*+ On Error 6oTo lErr Dim tot1 As Double= tot As Double Dim count1 As Double count1 , 4 P#ge(ount , 1 c2ec)%rint , F#lse If 8SF3Te0t8#tri0*1= 1+ 7H 11 T2en count1 , 2e#der%rint*count1= tot1= tot + For i , 1 To 8SF3Rows I 1 If count1 H, -- T2en count1 , fooder%rint*count1= tot1= tot = True+ P#ge(ount , P#ge(ount C 1 count1 , 2e#der%rint*count1= tot1= tot + End If c2ec)%rint , True Printer3FontSi@e , J Else mess#ge 1T2ere is no d#t# found1 End If tot1 , 4

tot , 4 E0it Sub lErr? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub (omm#nd '(lic)*+ sid , Rig2t*Te0t13Te0t= .en*Te0t13Te0t+ I 1+ ;D#t#En$ironment13rsPurc2#seOrder3O%en 1select E from %urc2#se w2ere %no, 1 9 /#l*sid+ 9 11 ;D#t#Re%ort13Sections*K+3(ontrols*1+ , rs ;D#t#Re%ort13s2ow ;D#t#En$ironment13rsPurc2#seOrder3(lose Te0t13Te0t , 11 End Sub Pri$#te Sub e0it1'(lic)*+ !nlo#d 8e End Sub Pri$#te Sub Form'Initi#li@e*+ d13SetFocus End Sub Pri$#te Sub cle#r'(lic)*+ 8SF3Rows , 8SF3cle#r 8SF3Form#tString , 1 S3No L Product (ode L Product N#me LMTN TNPELRATELL Mty L AmountLstoc)1 cm%'edit , F#lse cm%'delete , F#lse Te0t 3Te0t , 11 Te0t&3Te0t , 11 cle#rform Te0t13Te0t , getm#0$#l*1select m#0*%no+ #s $no from %urc2#se1+ Te0t13Te0t , 1P1 C Te0t13Te0t Fr#me 3/isible , F#lse d13/#lue , D#te #ddcombo1 #ddcombo Te0t13En#bled , True Te0t 3En#bled , True Te0t&3En#bled , True

s#$e3En#bled , True (ombo13En#bled , True (ombo 3En#bled , True (ombo&3En#bled , True t0t3/isible , F#lse 8SF13/isible , F#lse cm%'edit , F#lse ;d13SetFocus End Sub Pri$#te Sub (ombo1'FeyDown*Fey(ode As Integer= S2ift As Integer+ If Fey(ode , 1& T2en (ombo&3SetFocus End If End Sub Pri$#te Sub (ombo&'FeyDown*Fey(ode As Integer= S2ift As Integer+ If Fey(ode , 1& T2en (ombo 3SetFocus End If End Sub Pri$#te Sub (ombo 'FeyDown*Fey(ode As Integer= S2ift As Integer+ If Fey(ode , 1& T2en 8SF3col , 1 8SF3SetFocus End If End Sub Pri$#te Sub D1'FeyDown*Fey(ode As Integer= S2ift As Integer+ If Fey(ode , 1& T2en (ombo13SetFocus End If End Sub Pri$#te Sub Form'.o#d*+ #ddcombo1 #ddcombo cle#r'(lic) cle#rform Fr#me 3/isible , F#lse cm%'edit , F#lse End Sub Pri$#te Sub #ddcombo1*+ (ombo&3cle#r Set rs , dbm3O%enRecordset*1select su%n#me from su%%lier1= dbO%enDyn#set+ Do A2ile Not rs3EOF (ombo&3AddItem !(#se*rs>su%n#me+ rs38o$eNe0t

.oo% rs3(lose If (ombo&3.istInde0 H 4 T2en (ombo&3.istInde0 , 4 End Sub Pri$#te Sub #ddcombo *+ (ombo 3cle#r Set rs , dbm3O%enRecordset*1select em%n#me from em%loy1= dbO%enDyn#set+ Do A2ile Not rs3EOF (ombo 3AddItem !(#se*rs>em%n#me+ rs38o$eNe0t .oo% rs3(lose If (ombo 3.istInde0 H 4 T2en (ombo 3.istInde0 , 4 End Sub Pri$#te Sub cle#rform*+ 8SF3(olAlignment*4+ , 1 8SF3(olAidt2*4+ , *8SF3Aidt2 E -+ O 144 8SF3(olAlignment*1+ , 1 8SF3(olAidt2*1+ , *8SF3Aidt2 E 4+ O 144 8SF3(olAlignment* + , 1 8SF3(olAidt2* + , *8SF3Aidt2 E -+ O 144 8SF3(olAlignment*&+ , 1 8SF3(olAidt2*&+ , *8SF3Aidt2 E 14+ O 144 8SF3(olAlignment*<+ , 1 8SF3(olAidt2*<+ , *8SF3Aidt2 E 14+ O 144 8SF3(olAlignment*-+ , 1 8SF3(olAidt2*-+ , *8SF3Aidt2 E 4+ O 144 8SF3(olAlignment*K+ , 1 8SF3(olAidt2*K+ , *8SF3Aidt2 E 14+ O 144 8SF3(olAlignment*5+ , 1 8SF3(olAidt2*5+ , *8SF3Aidt2 E 14+ O 144 8SF3(olAlignment*G+ , 1 8SF3(olAidt2*G+ , *8SF3Aidt2 E 4+ O 144 For i , 1 To 8SF3Rows I 1 8SF3Te0t8#tri0*i= 4+ , i Ne0t i End Sub Pri$#te Sub msf'Enter(ell*+ On Error 6oTo lErr If 8SF3col , 1 T2en l#stte0t , 1msf11 t0t3Te0t , 8SF3Te0t8#tri0*8SF3row= 1+ t0t3Te0t , 11

findDty t0t3Te0t= 1 t0t38o$e [Link] C 8SF3([Link]= ' 8SF3To% C 8SF3(ellTo%= ' 8SF3(ellAidt2 I G= ' 8SF3(ellBeig2t I G t0t3/isible , True 8SF13/isible , True t0t3SetFocus End If #dd#mt E0it Sub lErr? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub findDty*findte0t As String= in0 As Double+ Dim rs As Recordset .ist13cle#r cle#rmsf1 If in0 , 1 T2en Set rs , dbm3O%enRecordset*1select E from %roduct w2ere %code li)e 1 9 1;1 9 findte0t 9 1E;1= dbO%enDyn#set+ End If Do A2ile Not rs3EOF If in0 , 1 T2en i,iC1 8SF13Rows , i C 1 8SF13Te0t8#tri0*i= 4+ , rs>%code 8SF13Te0t8#tri0*i= 1+ , rs>%n#me End If rs38o$eNe0t .oo% rs3(lose E0it Sub End Sub Pri$#te Sub cle#rmsf1*+ On Error 6oTo lErr 8SF13cle#r 8SF13Rows , 8SF13Form#tString , 1Product (odeLProduct N#me1 8SF13(olAidt2*4+ , 1G44

8SF13(olAlignment*4+ , 1 8SF13(olAidt2*1+ , &-44 8SF13(olAlignment*1+ , 1 E0it Sub lErr? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub #dd#mt*+ Dim tot1 As Double Dim Dty1 As Double tot , 4 For i , 1 To 8SF3Rows I 1 8SF3Te0t8#tri0*i= 5+ , /#l*8SF3Te0t8#tri0*i= <++ E /#l*8SF3Te0t8#tri0*i= K++ tot1 , tot1 C /#l*8SF3Te0t8#tri0*i= 5++ Dty1 , Dty1 C /#l*8SF3Te0t8#tri0*i= K++ Ne0t i Te0t 3Te0t , Dty1 Te0t&3Te0t , tot1 End Sub Pri$#te Sub msf'FeyPress*FeyAscii As Integer+ On Error 6oTo lErr Dim sTem% As String Ait2 8SF Select (#se 3col (#se 1= = & Select (#se FeyAscii (#se 1& If 3Te0t8#tri0*3row= 3col+ , 11 T2en msf'Enter(ell ElseIf 3Te0t8#tri0*3row= 3col+ 7H 11 T2en 8SF3col , 8SF3col C 1 E0it Sub End If (#se G E0it Sub )eybd'e$ent $bFeyRig2t= 4= 4= 4 )eybd'e$ent $bFeyRig2t= 4= FENE/ENTF'FEN!P= 4 ; rele#se B FeyAscii , 4 End Select (#se < If cm%'edit , True T2en 8SF3col , 8SF3SetFocus

E0it Sub End If sTem% , 3Te0t8#tri0*3row= 3col+ Select (#se FeyAscii (#se G ; b#c)s%#ce If .en*sTem%+ H 4 T2en sTem% , .eftP*sTem%= .en*sTem%+ I 1+ End If (#se 5 sTem% , 11 (#se 1& ; 3col , K 8SF3SetFocus sTem% , 11 ; (#se <K= <G To -5 sTem% , sTem% 9 (2rP*FeyAscii+ End Select (#se sTem% , 3Te0t8#tri0*3row= 3col+ Select (#se FeyAscii (#se G ; b#c)s%#ce If .en*sTem%+ H 4 T2en sTem% , .eftP*sTem%= .en*sTem%+ I 1+ End If (#se 5 sTem% , 11 (#se 1& ; 3col , K 8SF3SetFocus sTem% , 11 ;

(#se <K= <G To -5 sTem% , sTem% 9 (2rP*FeyAscii+ End Select (#se K sTem% , 3Te0t8#tri0*3row= 3col+ Select (#se FeyAscii (#se G ; b#c)s%#ce If .en*sTem%+ H 4 T2en sTem% , .eftP*sTem%= .en*sTem%+ I 1+ End If (#se 5 sTem% , 11 (#se 1& If 3Te0t8#tri0*3row= 1+ 7H 11 And /#l*form#t1*3Te0t8#tri0*3row= <+++ H 4 T2en If 3row , 3Rows I 1 T2en 3Rows , 3Rows C 1 For i , 1 To 3Rows I 1 3Te0t8#tri0*i= 4+ , i Ne0t i 3Te0t8#tri0*3row C 1= 1+ , 3Te0t8#tri0*3row= 1+ End If 3row , 3row C 1 3col , 1 msf'Enter(ell End If (#se <K= <G To -5 sTem% , sTem% 9 (2rP*FeyAscii+ End Select (#se $bFeyT#b s#$e3SetFocus ;End Select (#se 4 If FeyAscii , < T2en If 8SF3Rows 7H T2en For i , 8SF3row To 8SF3Rows I For j , 4 To 8SF3(ols I 1

8SF3Te0t8#tri0*i= j+ , 8SF3Te0t8#tri0*i C 1= j+ Ne0t j Ne0t i 8SF3Rows , 8SF3Rows I 1 End If For i , 1 To 3Rows I 1 3Te0t8#tri0*i= 4+ , i Ne0t i End If If FeyAscii , 1& T2en )eybd'e$ent $bFeyRig2t= 4= 4= 4 )eybd'e$ent $bFeyRig2t= 4= FENE/ENTF'FEN!P= 4 ; rele#se B End If End Select 3Te0t8#tri0*3row= 3col+ , sTem% #dd#mt End Ait2 E0it Sub lErr? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub 8SF1'Dbl(lic)*+ On Error 6oTo lErr For i , 1 To 8SF3Rows I 1 If 8SF3row 7H i T2en If 8SF3Te0t8#tri0*i= 1+ , 8SF13Te0t8#tri0*8SF13row= 4+ And 8SF3Te0t8#tri0*i= + , 8SF13Te0t8#tri0*8SF13row= 1+ T2en mess#ge 1Product Alre#dy Selected1 8SF13/isible , F#lse 8SF3Rows , 8SF3Rows I 1 8SF3col , K 8SF3SetFocus t0t3/isible , F#lse ;t0t3SetFocus E0it Sub End If End If Ne0t i 8SF3Te0t8#tri0*8SF3row= + , 8SF13Te0t8#tri0*8SF13row= 1+ 8SF3Te0t8#tri0*8SF3row= 1+ , 8SF13Te0t8#tri0*8SF13row= 4+ Dim rs1 As Recordset

Set rs1 , dbm3O%enRecordset*1select E from %roduct w2ere %code,;1 9 8SF3Te0t8#tri0*8SF3row= 1+ 9 1;1= dbO%enDyn#set+ If Not rs13EOF T2en 8SF3Te0t8#tri0*8SF3row= &+ , rs1>Ty%e rs13(lose End If 8SF3col , < 8SF3SetFocus t0t3/isible , F#lse 8SF13/isible , F#lse E0it Sub lErr? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub 8SF1'Fey!%*Fey(ode As Integer= S2ift As Integer+ If Fey(ode , 1& T2en 8SF1'Dbl(lic) End If End Sub Pri$#te Function c2ec)null*+ As "oole#n On Error 6oTo lErr Dim c2 As "oole#n Dim sid As Integer c2 , F#lse If Te0t13Te0t 7H 11 T2en Dim js As Recordset sid , Rig2t*Te0t13Te0t= .en*Te0t13Te0t+ I 1+ Set js , dbm3O%enRecordset*1select E from %urc2#se w2ere %no,1 9 sid 9 11= dbO%enDyn#set+ If Not js3EOF T2en mess#ge 1"ill No #lre#dy found1 Te0t13Te0t , 11 Te0t13SetFocus c2ec)null , F#lse E0it Function End If End If If Te0t13Te0t , 11 T2en mess#ge 1"ill Not Em%ty1 c2ec)null , F#lse Te0t13SetFocus E0it Function

End If If (ombo13Te0t , 11 T2en mess#ge 18ode is not Em%ty1 c2ec)null , F#lse (ombo13SetFocus E0it Function End If If (ombo 3Te0t , 11 T2en mess#ge 1S#les N#me not Em%ty1 c2ec)null , F#lse (ombo 3SetFocus E0it Function End If If (ombo&3Te0t , 11 T2en mess#ge 1Su%%lier N#me not Em%ty1 c2ec)null , F#lse (ombo 3SetFocus E0it Function End If For i , 1 To 8SF3Rows I 1 If 8SF3Te0t8#tri0*i= 1+ , 11 And 8SF3Te0t8#tri0*i= + , 11 And 8SF3Te0t8#tri0*i= &+ , 11 And 8SF3Te0t8#tri0*i= <+ , 11 And 8SF3Te0t8#tri0*i= -+ , 11 And 8SF3Te0t8#tri0*i= K+ , 11 And 8SF3Te0t8#tri0*i= 5+ , 11 T2en mess#ge 1(om%lete t2e rows1 8SF3SetFocus c2ec)null , F#lse E0it Function End If Ne0t i c2ec)null , True E0it Function lErr? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Function Pri$#te Sub s#$e'(lic)*+ Dim rs1 As Recordset Dim rs As Recordset

Dim sid As Integer If cm%'edit , True T2en sid , Rig2t*Te0t13Te0t= .en*Te0t13Te0t+ I 1+ dbm3E0ecute 1delete E from %urc2#se w2ere %no,1 9 sid 9 11 For i , 1 To 8SF3Rows I 1 Set rs , dbm3O%enRecordset*1select E from stoc) w2ere %code,;1 9 8SF3Te0t8#tri0*i= 1+ 9 1;1= dbO%enDyn#set+ If /#l*8SF3Te0t8#tri0*i= K++ H /#l*8SF3Te0t8#tri0*i= G++ T2en rs3Edit rs>Dty , *rs>Dty C */#l*8SF3Te0t8#tri0*i= K++ I /#l*8SF3Te0t8#tri0*i= G++++ rs>%rice , /#l*8SF3Te0t8#tri0*i= <++ rs3!%d#te ElseIf /#l*8SF3Te0t8#tri0*i= K++ 7 /#l*8SF3Te0t8#tri0*i= G++ T2en rs3Edit rs>Dty , *rs>Dty I */#l*8SF3Te0t8#tri0*i= G++ I /#l*8SF3Te0t8#tri0*i= K++++ rs>%rice , /#l*8SF3Te0t8#tri0*i= <++ rs3!%d#te End If Ne0t i rs3(lose If c2ec)null , True T2en For i , 1 To 8SF3Rows I 1 Set rs1 , dbm3O%enRecordset*1select E from %urc2#se1= dbO%enDyn#set+ rs13AddNew rs1>%no , sid rs1>%#yment , (ombo13Te0t rs1>sn#me , (ombo&3Te0t rs1>D#te , d13/#lue rs1>em%n#me , (ombo 3Te0t rs1>%code , 8SF3Te0t8#tri0*i= 1+ rs1>%n#me , 8SF3Te0t8#tri0*i= + rs1>Dtyty%e , 8SF3Te0t8#tri0*i= &+ rs1>%rice , 8SF3Te0t8#tri0*i= <+ rs1>Dty , 8SF3Te0t8#tri0*i= K+ rs1>tot , 8SF3Te0t8#tri0*i= 5+ rs1>totDty , /#l*Te0t 3Te0t+ rs1>tot#mt , /#l*Te0t&3Te0t+ rs1>St#tus , 1P!R(BASE EDIT1 rs13!%d#te Ne0t i rs13(lose 8sg"o0 1Record Edited Successfully1 cm%'edit , F#lse cle#r'(lic) E0it Sub

End If ElseIf cm%'edit , F#lse T2en If c2ec)null , True T2en sid , Rig2t*Te0t13Te0t= .en*Te0t13Te0t+ I 1+ Set rs , dbm3O%enRecordset*1select E from %urc2#se1= dbO%enDyn#set+ For i , 1 To 8SF3Rows I 1 rs3AddNew rs>%no , sid rs>%#yment , (ombo13Te0t rs>sn#me , (ombo&3Te0t rs>D#te , d13/#lue rs>em%n#me , (ombo 3Te0t rs>%code , 8SF3Te0t8#tri0*i= 1+ rs>%n#me , 8SF3Te0t8#tri0*i= + rs>Dtyty%e , 8SF3Te0t8#tri0*i= &+ rs>%rice , 8SF3Te0t8#tri0*i= <+ rs>Dty , 8SF3Te0t8#tri0*i= K+ rs>tot , 8SF3Te0t8#tri0*i= 5+ rs>totDty , /#l*Te0t 3Te0t+ rs>tot#mt , /#l*Te0t&3Te0t+ rs>St#tus , 1NEA1 rs3!%d#te Ne0t i rs3(lose For i , 1 To 8SF3Rows I 1 Set rs , dbm3O%enRecordset*1select E from stoc) w2ere %code,;1 9 8SF3Te0t8#tri0*i= 1+ 9 1;1= dbO%enDyn#set+ If Not rs3EOF T2en rs3Edit rs>Dty , /#l*8SF3Te0t8#tri0*i= K++ C rs>Dty rs>%rice , /#l*8SF3Te0t8#tri0*i= <++ rs3!%d#te ElseIf rs3EOF T2en rs3AddNew rs>%code , 8SF3Te0t8#tri0*i= 1+ rs>%n#me , 8SF3Te0t8#tri0*i= + rs>Dtyty%e , 8SF3Te0t8#tri0*i= &+ rs>%rice , 8SF3Te0t8#tri0*i= <+ rs>Dty , 8SF3Te0t8#tri0*i= K+ rs3!%d#te End If Ne0t i End If 8sg"o0 1Record Added Successfully1

cle#r'(lic) End If End Sub Pri$#te Sub Te0t1'FeyPress*FeyAscii As Integer+ If FeyAscii , 1& T2en Dim sid As Integer sid , Rig2t*Te0t13Te0t= .en*Te0t13Te0t+ I 1+ Set rs , dbm3O%enRecordset*1select E from %urc2#se w2ere %no,1 9 sid 9 11= dbO%enDyn#set+ Do A2ile Not rs3EOF If rs>St#tus , 1P!R(BASE RET!RN1 T2en 8sg"o0 1(#nnot Return1 s#$e3En#bled , F#lse E0it Sub End If rs38o$eNe0t .oo% Set rs , dbm3O%enRecordset*1select E from %urc2#se w2ere %no,1 9 sid 9 11= dbO%enDyn#set+ If Not rs3EOF T2en Do A2ile Not rs3EOF (ombo13Te0t , rs>%#yment (ombo 3Te0t , rs>em%n#me (ombo&3Te0t , rs>sn#me d13/#lue , rs>D#te i,iC1 8SF3Rows , i C 1 8SF3Te0t8#tri0*i= 4+ , i 8SF3Te0t8#tri0*i= 1+ , rs>%code 8SF3Te0t8#tri0*i= + , rs>%n#me 8SF3Te0t8#tri0*i= &+ , rs>Dtyty%e 8SF3Te0t8#tri0*i= <+ , rs>%rice 8SF3Te0t8#tri0*i= K+ , rs>Dty 8SF3Te0t8#tri0*i= 5+ , rs>tot 8SF3Te0t8#tri0*i= G+ , rs>Dty Te0t 3Te0t , rs>totDty Te0t&3Te0t , rs>tot#mt rs38o$eNe0t .oo% ;ElseIf rs3EOF T2en ;8sg"o0 1(#nnot Return1 ;S#$e3En#bled , F#lse

End If rs3(lose 8SF3row , 1 8SF3col , 8SF3SetFocus End If cm%'edit , True End Sub Pri$#te Sub t0t'FeyPress*FeyAscii As Integer+ On Error 6oTo lErr If 8SF3col , 1 T2en Select (#se FeyAscii (#se 1& If Trim*8SF13Te0t8#tri0*1= 4++ , 11 T2en t0t3SetFocus Else 8SF1'Dbl(lic) End If End Select ElseIf 8SF3col , < T2en Select (#se FeyAscii (#se 1& 8SF3Te0t8#tri0*8SF3row= <+ , !(#se*t0t3Te0t+ t0t3/isible , F#lse 8SF3SetFocus End Select End If E0it Sub lErr? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub t0t'Fey!%*Fey(ode As Integer= S2ift As Integer+ On Error 6oTo lErr If 8SF3col , 1 T2en Select (#se Fey(ode (#se 5 For i , 1 To 8SF3(ols I 1 8SF3Te0t8#tri0*8SF3row= i+ , 11 Ne0t i 8SF13/isible , F#lse

t0t3/isible , F#lse 8SF3SetFocus (#se <4 8SF13SetFocus (#se Else l#stte0t , 1msf1 8SF13/isible , True findDty t0t3Te0t= 1 End Select End If If 8SF3col , & T2en Select (#se Fey(ode (#se 5 Fr#me 3/isible , F#lse t0t3/isible , F#lse 8SF3SetFocus (#se <4 .ist13SetFocus (#se Else l#stte0t , 1fsi@e1 Fr#me13/isible , True findDty t0t3Te0t= 1 End Select End If E0it Sub lErr? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub .ist1'Dbl(lic)*+ On Error 6oTo lErr Dim rs As Recordset Select (#se l#stte0t (#se 1msf11 If .[Link](ount , 4 T2en 8SF3SetFocus End If (#se 1msf 1 If .[Link](ount , 4 T2en 8SF3SetFocus Else 8SF3Te0t8#tri0*8SF3row= + , .[Link]*.ist13.istInde0+ t0t3/isible , F#lse

8SF3col , < 8SF3SetFocus End If End Select E0it Sub lErr? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub .ist1'Fey!%*Fey(ode As Integer= S2ift As Integer+ On Error 6oTo lErr Select (#se Fey(ode (#se G= 5 Select (#se l#stte0t (#se 1te0t 1 Te0t 3SetFocus (#se 1msf11 8SF3SetFocus End Select (#se 1& .ist1'Dbl(lic) End Select E0it Sub lErr? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub Pri$#te Sub msf'.e#$e(ell*+ On Error 6oTo lErr Dim tot As Double Fr#me 3/isible , F#lse t0t3/isible , F#lse E0it Sub lErr? 8sg"o0 (Str*Err3Number+ 9 Err3Descri%tion= $b(ritic#l= 1Inform#tion1 Resume Ne0t End Sub

You might also like