Home > Software engineering >  High marks for help and advice on VB, very wonderful work code, very wonderful work error, is this a
High marks for help and advice on VB, very wonderful work code, very wonderful work error, is this a

Time:10-04


You greatly, they help me have a look at the following code where in addition to the problem,
I am going to do in TEXT2 associated, when the input test2 company name in the text box will compound conditions of company records show to LIST3, double-click LIST3, according to the company name will be the company's contact information, telephone, address etc to display interface corresponding text box,
Results very wonderful work, found that has an error, the more wonderful work, if the code to create a new interface to go up is normal, and there is an error "in the name of the corresponding to the required or Ordinal Numbers in the collection, project" was not found,
But clearly it was a record, data format is a text format, so can't find the project, why is this? The same code on a new project or FRM, it is normal, whether grammatically, database structure is no problem, because the same code, the same database, and even on other projects, other FRM can run normally, but an error in the SUB,
Is this a BUG?
Private Sub List3_Click ()
MsgBox Trim (List3. List (List3 ListIndex))
'On the Error Resume Next
TkOpenAccessDB 'connect to the database
If sts2. State=adStateOpen Then sts2. Close 'without any records enable
Sts2. Open the "select * from customer data where companies like '" & amp; Trim (List3. List (List3. ListIndex)) & amp; "'", CNN, adOpenKeyset, adLockOptimistic, adCmdText
If Not sts2. EOF Then
Sts2. MoveFirst
If the Trim (sts2 Fields (7)) & lt;> "" Then Text2. Text=Trim (sts2. Fields (7))
'companyIf the Trim (sts2 Fields (1)) & lt;> "" Then Text3. Text=Trim (sts2. Fields (1)) 'contact
If the Trim (sts2 Fields (2)) & lt;> "" Then Combo1. Text=Trim (sts2. Fields (2))
'countriesIf the Trim (sts2 Fields (4)) & lt;> "" Then Text4. Text=Trim (sts2. Fields (4)) 'E-mail

End the If
Sts2. Close
List3. Visible=False
End Sub


CodePudding user response:

TkOpenAccessDB 'is this link the database function, there is no problem

CodePudding user response:

VB6 is sometimes like that, I also didn't find the reason,

CodePudding user response:

Remove sts2. MoveFirst try:

Text2. Text=Trim (sts2. Fields (7)) & amp; "" 'company
Text3. Text=Trim (sts2 Fields (1)) & amp; "' contact
Combo1. Text=Trim (sts2 Fields (2)) & amp; "
'countriesText4. Text=Trim (sts2. Fields (4)) & amp; "' E-mail

CodePudding user response:

Text2. Text=Trim (sts2. Fields (7)) & amp; "" 'company
Text3. Text=Trim (sts2 Fields (1)) & amp; "" 'contact
Combo1. Text=Trim (sts2 Fields (2)) & amp; "" 'national
Text4. Text=Trim (sts2. Fields (4)) & amp; "" 'E-mail

CodePudding user response:

Source code is only part of your input, control properties, the design of the report, etc in usd. The DSR file, such as using file comparison tool to find differences,

Lazy way is to use without fault on the surface of the New Territories to replace the old file,

CodePudding user response:

This is generally the field name in the database with the field name in the code

CodePudding user response:

1, is the debug see your cmdtext

That is the select XXXXX

Data into the database inside looking for return

2, see your sts2. Recordcount is greater than 0

3, look at your sts2. Fields (1) is null

CodePudding user response:

The affirmation of things you have to record set no including you specify the column in the unit

CodePudding user response:

Your data sets exported to look at to know...

CodePudding user response:

If isnull (sts2 fields (2))=true then
Text3. Text=""
The Else
Text3. Text=sts2. Fields (2)
End the if
You, is the cause of error text box does not recognize the database field data is null

CodePudding user response:

To display the field name does not appear in your code, this tip, can only be seen

CodePudding user response:

At this moment can enter in the immediate window:? Sts2. Fields. Count how much is the return to see
If more than 2, : again? Sts2. Fields (1). Look at what is the name enter
In fact after all, is the debug program. This kind of matter need your patience to find the problem.
  • Related