Home > Software engineering >  Seek expert help answer. Why don't you run ah..
Seek expert help answer. Why don't you run ah..

Time:09-25

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...

CodePudding user response:

reference 1st floor Topc008 response:
...
In addition, in your SQL=... Behind the statement setting a breakpoint or add a line debug. Print SQL and see what the result is...

His assignment is obvious,


In VB6 as C/C + +, Java language such as "escape" character, in the "string enclosed in double quotation marks are used to,
If you want to put the double quotation marks as the content of the string, can be expressed in successive two double quotes a double quotation marks,
(this may be the only "escape character" in VB6 )
Or, all the double quotes in your SQL statements to single quotes,

CodePudding user response:

Look problem is more, the first Do While ABC. EOF had problems with this statement mean when recordset is to enter at the end of a pointer to the Do loop, does it make sense to the home page? Should be modified to Do While Not the ABC. The EOF, this is the record set pointer Not arrived at the end to enter the Do loop, exit after arrived at the end of the cycle,

ABC. Open "EEE", AAA,,, where is the EEE in adCmdTable, AAA back three, number is wrong? EEE is connection string data tables, there is no connection EEE?

The two objects you statement is SP2 statement format before, there is no such statement after SP2, should be like this:
 Dim AAA As New ADODB. Connection 
Dim ABC As New ADODB. You
can, do not need to Set the AAA=CurrentProject. Connection statements, such As

CodePudding user response:

Today saw your program, the problem is very much, must have run up, namely is up and running, also have no way to run down,
You must first build a database, there are two data in the database table, DDD, EEE, no database how to run? Give you do a simple:
 Dim AAA As New ADODB. Connection, ABC As New ADODB library. You, CDE As New ADODB. You 

Sub KKK (AAA)
AAA. The ConnectionString="Provider=Microsoft. ACE. The OLEDB. 12.0; Data Source="& amp; App. The Path & amp; "\ BBB1 accdb
"AAA. Open
End Sub

Private Sub Form_Load ()
Call KKK (AAA)
CDE. Open the "Select * From EEE", AAA, 3, 2
EOF
the Do While Not CDE.ABC. Open the "Select * From DDD WHERE commname LIKE '%" & amp; CDE. Fields (2) & amp; "%", "AAA, 3, 2
EOF
the Do While Not the ABC.ABC. Fields (1)=CDE. The Fields in the table (2) 'will be EEE commno DDD table to store the value of the corresponding field of sysno
The Update
ABC. MoveNext
Loop
ABC. Close
CDE. MoveNext
Loop
CDE. Close
AAA. Close
MsgBox "finished!"
End Sub

Is not very complicated, look at the picture, the left is the DDD before operating table, on the right is the DDD to that of table
  •  Tags:  
  • VBA
  • Related