I got 1 file ( Trade.mdb ).. Inside this file I got 3 table which is Data151, MKCW442 and KOR_tbl.. I already right the coding.. But it still didn't work..
So when user choose file Data151 and click button process.. I want it to be like this:
1. Read the field Ctry. If the field Ctry = Asean Country which is ( MY, TH, SG, BN, ID, PH, KH, MM, VN, LA ) then have to compare with field HS in table Data151 and compare also with field AHTN 2004 or field AHTN_ABJAD 2004 in table Master1
2. If same, then transfer the all information from field AHTN10_2007 in table Master1 to the new table ( Output )
3.Transfer all the information that have been modified or not to the new table ( Output )
3. After finish process, must come out one message box which is PROCESS COMPLETED
Code:
Private Sub cmdProses_Click()
Dim strpilih As String
Dim strpilih2 As String
Dim strpilih3 As String
Dim rspilih As Recordset
Dim rspilih2 As Recordset
Dim rspilih3 As Recordset
'When user choose eg. Input151 then click the button Process, this will happen :
'Read the field Ctry (From table Data151)
'If field Ctry =Asean Country which is (MY,TH,SG,BN,ID,PH,KH,MM,VN,LA)
'Then have to compare field HS (From table Data151) with field AHTN2004 or AHTN_ABJAD 2004 (From table KOR_tbl)
'If same, then transfer all the information from field AHTN10_2007 (From table KOR_tbl) to the field hscode (New table which is Output)
'Transfer all the records that had been modified or not to the new table (Output)
'After finish process, must come out the message box " PROCESS COMPLETED "
If Pilihan.Text = "Input151" Then
Set rspilih = New Recordset
strpilih = "Select * from Data151"
rspilih.Open strpilih, cn2, adOpenForwardOnly, adLockReadOnly
rspilih.MoveFirst
Do While Not rspilih.EOF
Loop
MsgBox rspilih.Fields("Ctry")
If rspilih.Fields("Ctry") = "MY" Then
'compare field hscode table INPUT151 with field AHTN 2004/field AHTN_ABJAD 2004 (table KOR_tbl)
Set rspilih2 = New Recordset
strpilih2 = ("Select * HS from Data151") And ("Select * (AHTN 2004 OR AHTN_ABJAD 2004 ) from KOR_tbl")
rspilih2.Open strpilih2, cn1, adOpenForwardOnly, adLockReadOnly
rspilih2.MoveFirst
Do While Not rspilih2.EOF
'If same, then transfer all the information from field AHTN10_2007 (From table KOR_tbl) to the field hscode (New table which is Output)
Set rspilih3 = New Recordset
strpilih3 = ("Select * AHTN10_2007 from table KOR_tbl")
rspilih3.Open strpilih3, cn3, adOpenForwardOnly, adLockReadOnly
End If
End Sub
Thank you so so much...