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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urget Help - Find using criteria giving error

Status
Not open for further replies.

incagold

Programmer
Mar 21, 2003
54
0
0
Hi All,

Newbie back with another problem. This is rather urgent, so any help would be greatly appreciated.

The problem is we have a form with a command button that when clicked will search a table to see if a record exists, if not it displays additional text boxes for input. We tried using a function that we have used frequently in ACC2000 but now gives us an error using XP. The error is:

The Microsoft Jet database engine does not recognize 'jones' as a valid field name or expression.

This is the code:

Private Sub cmdSubmit_Click()
On Error GoTo Err_cmdSubmit_Click

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strCriteria As String
Dim strSender As String

strSender = Me.txtLName.Value
strCriteria = "[Last_Name] =" & strSender
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblSENDER", dbOpenDynaset)
'*** Search table for Sender
rst.FindNext strCriteria
'*** If not present ask Sender to input data
If rst.NoMatch Then
Dim Msg, Style, Title, Response
Msg = "Your Name Is Not Currently On File "
Msg = Msg & vbCr & vbCr & "Please Complete The Information Below."
Style = vbOKOnly + vbExclamation
Title = "SENDER NAME NOT ON RECORD"
Response = MsgBox(Msg, Style, Title)
Me.lblFirst.Visible = True
Me.txtFName.Visible = True
Me.lblTle.Visible = True
Me.txtTitle.Visible = True
Me.lblExn.Visible = True
Me.txtExt.Visible = True
Me.txtLName.SetFocus
Me.txtLName.Value = ""
End If
rst.Close
Set dbs = Nothing
DoCmd.Close

Exit_cmdSubmit_Click:
Exit Sub

Err_cmdSubmit_Click:
MsgBox Err.Description
Resume Exit_cmdSubmit_Click

End Sub

We have tried everything that we know with our limited knowledge. The routine has worked in ACC2000 without incident. What have we missed? Again, any help would be appreciated. Thanks in advance.

EAF
 
Try this...

strCriteria = "[Last_Name] =""" & strSender &
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top