Dim cn As New ADODB. Connection
Dim rs1 As New ADODB. You 'original Recordset
Dim rs2 As New ADODB. You 'each page of the record set
Dim intPage As Integer 'current page
Private Sub rsPage (ByRef rsFirst As you, ByVal intPageNumber As Integer)
Dim I As an Integer, j As Integer
For I=0 To rsFirst. Fields. The Count - 1 "To create a new table rs2, related Fields To join
Rs2. Fields. Append rsFirst. Fields (I). The Name, rsFirst. Fields (I) Type, rsFirst. Fields (I). DefinedSize, rsFirst. Fields (I). The Attributes
Next I
Rs2. Open
RsFirst. AbsolutePage=intPageNumber
For I=1 To rsFirst. PageSize 'of the corresponding page data is copied To the new table rs2
Rs2. AddNew
For j=0 To rsFirst Fields. The Count - 1
Rs2. Fields (j)=rsFirst. Fields (j)
Next j
Rs2. Update
RsFirst. MoveNext
If rsFirst. EOF Then Exit For 'judge whether to end, because the last time, may not be the whole size
Next I
The Set HFG. The DataSource=rs2
Rs2. Close
End Sub
Private Sub Command1_Click ()
If (Text1. Text) & gt; 0 Then 'if the user specifies the code
Cn.Com mandType definition=adCmdText 'record source
Cn. RecordSource="select * from student where student id='" & amp; Text1. Text & amp; "'
"Cn. Refresh 'gives effect to the property of the set
End the If
End Sub
Private Sub Form_Load ()
Cn. The Open ". The Provider=Microsoft Jet. The OLEDB. 4.0; The Data Source=F: \ cxj_joya \ VB \ database12 MDB
""Rs1. Open the" select * from students, cn, adOpenKeyset, adLockOptimistic, adCmdText
IntPage=0
Rs1. PageSize=4 'set the record page size and page in the current record of the initial value
'Set HFG.=cn' DataSource Settings datagrid control data source for the ADO data control result Set
End Sub
CodePudding user response:
Something wrong?CodePudding user response:
My purpose is from text box to enter search text, and then in the datagrid in order to find the scroll down,CodePudding user response:
Private Sub Cmdsearch_Click () 'search
If (Text1. Text) & gt; 0 Then 'if the user specifies the code
Adodc1.Com mandType definition=adCmdText 'record source
Adodc1. RecordSource="select * from student where student id='" & amp; Text1. Text & amp; "'
"Adodc1. Refresh 'gives effect to the property of the set
End the If
End Sub
Private Sub initgrid () 'initialize dtgcond controls
With dtgcond
Columns (0). The Caption="student id" 'set the column headings
Columns (1). The Caption="name"
End With
End Sub
Private Sub Form_Load ()
Set dtgcond.=Adodc1 'DataSource Settings datagrid control data for the ADO data control result Set
Call initgrid
Adodc1. Visible=False
End Sub
CodePudding user response:
Lookup shows only one at a time, when find the second text, before a lookup records are covered, help to look at, thank you.CodePudding user response:
Query or search the hell are you?Queries are all show only qualified record, must cover the last result,
To locate is on display in the eligible records, always no refresh/coverage data,
Private Sub Cmdsearch_Click () 'search
Dim the rs As the adodb library you
If LenB (Text1. Text) & gt; 0 Then
Set the rs=Adodc1. You. Clone ()
'this is from the current under a continue to search,'
Rs. Find "student id='" & amp; Text1. Text & amp; "'", 1, adSearchForward dtgcond. Bookmark
'from scratch using the following search,'
'rs. Find "student id=" & amp; Text1. Text & amp; "'," 0, adSearchForward, adBookmarkFirst
If the rs. EOF Then
MsgBox "is not found!" , vbInformation
The Else
Dtgcond. Bookmark=rs. Bookmark
End the If
End the If
End Sub
CodePudding user response:
Sorry, I didn't say understand, is to find, has been solved, just began to learn VB. Control and database application many do not understand, thank you for your advice!CodePudding user response:
With your statement tried, clearly the ACCESS of the data, but said not found after running? Can help to analysis? Don't, qq chat?CodePudding user response:
In the table to see the record?Lookup is in existing records in the positioning,
CodePudding user response:
There are in the form, but to find not to come out,CodePudding user response:
Student id field type characters or Numbers? Written notice conditions,Whitespace characters in the field values?
Text1 Spaces?
Use from the beginning to find statements a try,
CodePudding user response:
Rs. Find "student id='" & amp; Text1. Text & amp; "'," 0, adSearchForward, adBookmarkFirstStudent id field types are characters, on the run out of the question,
CodePudding user response:
Debug. Print "student id='" & amp; Text1. Text & amp; "'"
What results,
Copy the conditions to Access the query as a condition to perform,