Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query returns no records when records exist

Status
Not open for further replies.

SteveWillett

Programmer
Oct 14, 2011
4
US
I have an Access continual form with two buttons to open other forms for the selected record. One button works, finds the record, and opens the form, the other reports a Recordset EOF (shows the "No client with clint ID" message).

Any thoughts on what might cause the same query to fail in one place but succeed in another? I am displaying the SQL in both subroutines and they appear identical.

Here is the code for these two buttons:

Private Sub cmdEditSelectedClient_Click()
Dim db As Database
Dim rs As Recordset
Dim strSQL As String ''

Set db = CurrentDb
strSQL = "SELECT * FROM clients WHERE clientID=" & Me.id
MsgBox strSQL
Set rs = db.OpenRecordset(strSQL)
If Not rs.EOF Then
DoCmd.OpenForm "Entry Form", acNormal, , , , , Me.id
Else
MsgBox "No client with clientID = " & Me.id
End If
rs.Close

End Sub

Private Sub cmdRescreen_Click()
Dim db As Database
Dim rs As Recordset
Dim strSQL As String

Set db = CurrentDb
strSQL = "SELECT * FROM clients WHERE clientID=" & Me.id
MsgBox strSQL
Set rs = db.OpenRecordset(strSQL)
If Not rs.EOF Then
DoCmd.OpenForm "Re-screen Form", acNormal, , , , , Me.id
Else
MsgBox "No client with clientID = " & Me.id
End If
rs.Close

End Sub
 
The two buttons are on the very same form ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes, the two buttons are on the same form. See screenshot:

Client%20List.jpg
 
Never Mind - the problem was actually on the Re-screen Form in the Form_Open method...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top