Please help with my syntax OR SUGGEST A BETTER WAY. I am retrieving a single record from an SQL table. Once retrieved, will display existing values, allow changes, then write the whole record back to the table. Adding and deleting recs works great, but can't get the syntax correct to retrieve the single rec for updating. Have two displays in for diagnostic purposes: one to show the actual sql line, the other trying to display a field for the record I am looking for. My second msgbox always shows blanks or null. Should show a text value.Have no problem with manipulating the form, just can't seem to get the record. Have verifed search criteria. My code is shown below.
The msgbox for sqlstr shows:
select * from Asset_Table WHERE ([A_AssetN]) = "11-1-11-00-0001";
Your help is greatly appreciated !
Bob
Code:
Private Sub Command98_Click()
On Error GoTo Err_Command98_Click
Dim db As Object
Dim rst As Object
Dim sqlstr As String
Set db = CurrentDb
sqlstr = "Select * FROM Asset_Table WHERE ([A_AssetN]) = " & Chr$(34) & Me!AI_AssetN & Chr$(34) & ";"
Set rst = db.OpenRecordset(sqlstr, dbOpenDynaset)
MsgBox sqlstr
MsgBox (A_RType)
Rem DoCmd.RunSQL sqlstr
Exit_Command98_Click:
Exit Sub
Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End Sub