CodePudding user response:
This mainly by writing SQL statements, need other skill rarely,CodePudding user response:
Scanning one eye, I create a new project, to join two text controls, text1 text input is 1, the back of the SQL statement conditions text1. The text is 1, then add the adodb library reference, to write a piece of code that is not in conformity with your request, is the same reason,Cnopen a simple process, 'open the database, the omitted, cn, rs, is not explained,
Set the rs=New ADODB. You
Rs. Open the "SELECT employees. Employee ID, employee. Surname, employees. Name, employees. Position From where employees. Employee ID=" & amp; Text1. Text, cn, 1, 1
'If the rs. State & lt;> AdStateClosed Then rs. Close
Rs. MoveFirst
Dim I, a
For I=0 To rs. 'Fields. The Count - 1-1 b can also, b has the assignment in the front. The cycle instead of behind the five words, both the same, but it is different modular,
A=b & amp; Rs. Fields (I)
'CellAlignment (I)=flexAlignCenterCenter
Next
Text2. Text=a
CodePudding user response:
People don't know your database, the table name and field, record, just give me some principles,For example, I use Microsoft northwind database, table named employees, query field as the employee ID, according to the content of the input control text1 to query, SQL statements roughly "select * from employee where employees ID=1", or in control after went like this:
"Select * from employee where employees ID=" & amp; Text1. Text
I outside the two text1 controls, add a command button that in text1 input 2, press the button, just recorded output to text2.
Private Sub Command1_Click ()
Cnopen 'open the database connection methods, explain omitted,
Set the rs=New ADODB. You
Rs. Open the "SELECT employees. Employee ID, employee. Surname, employees. Name, employees. Position From where employees. Employee ID=" & amp; Text1. Text, cn, 1, 1
Dim I, a
For I=0 To rs. Fields. The Count - 1
A=b & amp; Rs. Fields (I)
Next
Text2. Text=a
Rs. Close
Set the rs=Nothing
Cn. Close
The Set cn=Nothing
End Sub
In TEXT1 enter 1, you can return a record; Input 5, can return to a record, and display in TEXT2,
CodePudding user response:
More troublesome is the determination of "line 5"Access data table will not guarantee data row, even if you are sure there are fifth in the row in the table, unless you're at query time using the Order By clause, according to one or some column values to sort, for example, you have automatic increment field, and the field values for 5 record is not deleted,
CodePudding user response:
What "the fifth line," this is the database and not excelCodePudding user response: