Database has 2 form in the AAA, DDD (commodity information table) and EEE (inventory), EEE (list of goods) in Sysno number (system) and commno (product id) in two fields, system number corresponding a single commodity number, DDD (commodity information table) in the two fields, Sysno number (system) and commname (name of commodity),,
Requirements: from the commodity name (DDD commname) in the table fields, looking for containing the list of goods commodity code (EEE - commno) fields, and the corresponding system code update into the DDD form corresponding position,
DDD EEE
Sysno commname sysno commno
(empty) samsung NH004 TV S01 NH004
(empty) NH004 samsung TV S02 MI001
(empty) millet MI001 TV
(empty) millet TV MI001
(empty) samsung TV NH004
(empty) MI001 millet TV
Automatically (empty) character of DDD assignment
Option Compare Database
Sub Date_SysNoInput ()
Dim AAA As ADODB. Connection
Dim ABC As ADODB. You
Set the AAA=CurrentProject. Connection
The Set of ABC=New ADODB. You
ABC. LockType=adLockBatchOptimistic
ABC. Open "EEE", AAA,,, adCmdTable
Dim bl_sysno As String
Dim bl_commno As String
Dim As SQL String
The Do While the EOF
Bl_sysno=ABC! SysNo
Bl_commno=ABC! CommNo
ABC. MoveNext
SQL="UPDATE (DDD) SET [DDD] SysNo=" bl_sysno " The WHERE ((((DDD). CommName)="bl_commno" Or ([DDD]. CommName) Like "* bl_commno" Or ([DDD]. CommName) Like bl_commno "* *" Or ([DDD]. CommName) Like "bl_commno *"));"
DoCmd. RunSQL "SQL"
Loop
ABC. Close
AAA. Close
The Set of ABC=Nothing
The Set of AAA=Nothing
End Sub
CodePudding user response:
Tips: 1, the code can not run that is your problem===& gt; You have to make the code can run up; 2, the code to run after an error, identify the location of the error and error; 3, the code, the best here:
your code, it looks more comfortable,
In addition, in your SQL=... Behind the statement setting a breakpoint or add a line debug. Print SQL and see what the result is...