Can someone help me with this.
I have a form with a find command button(cmdFind).
I'm using ADO, VB and Access.
It works but the VB code must be changed to
Sql as a requirement of the project.
The code in Vb needs to be converted to
Sql is as follows.
Private Sub cmdFind()
Dim strLast As String
Dim adoBookmark As Variant
strLast = InputBox("Enter Studentid for search"
If strLast <> "" Then
adoBookmark = Adodc1.Recordset.Bookmark
Adodc1.Recordset.Find "Studentid = " & strLast
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.Bookmark = adoBookmark
MsgBox "Student not Found"
End If
End If
End Sub
The code I am laboring over to try to make work is:
Private Sub cmdFind_Click()
Dim StudentFind As String
Dim sqlFind As String
StudentFind = InputBox("Enter StudentID", "Find Student by Studentid"
sqlFind = "SELECT * FROM Student " & _
"WHERE Studentkey = " & StudentFind
Adodc1.RecordSource = sqlFind
Adodc1.Refresh
end sub
This is on Access tables.
Can anyone look at this and see why it has a problem.
thanks.
John
I have a form with a find command button(cmdFind).
I'm using ADO, VB and Access.
It works but the VB code must be changed to
Sql as a requirement of the project.
The code in Vb needs to be converted to
Sql is as follows.
Private Sub cmdFind()
Dim strLast As String
Dim adoBookmark As Variant
strLast = InputBox("Enter Studentid for search"
If strLast <> "" Then
adoBookmark = Adodc1.Recordset.Bookmark
Adodc1.Recordset.Find "Studentid = " & strLast
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.Bookmark = adoBookmark
MsgBox "Student not Found"
End If
End If
End Sub
The code I am laboring over to try to make work is:
Private Sub cmdFind_Click()
Dim StudentFind As String
Dim sqlFind As String
StudentFind = InputBox("Enter StudentID", "Find Student by Studentid"
sqlFind = "SELECT * FROM Student " & _
"WHERE Studentkey = " & StudentFind
Adodc1.RecordSource = sqlFind
Adodc1.Refresh
end sub
This is on Access tables.
Can anyone look at this and see why it has a problem.
thanks.
John