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

FindFirst not working, Access 2K

Status
Not open for further replies.

KaminskiT

Programmer
Jul 11, 2007
1
US
The code returns 'No match found' when the Case_Id does exist in the recordset. The control on the form holds a text value. The field [fld_CASE_ID]in recordset(table)is a number. How do I fix this? Thanks for reading.

Code:
Public Sub subGetCase()

Dim curDB As DAO.Database
Dim grst As DAO.Recordset
Dim strCriteria As String
        
Set curDB = CurrentDb()
Set grst = curDB.OpenRecordset("tbl_SectionABCD_Amounts", DB_OPEN_DYNASET)

strCriteria = "[fld_CASE_ID] = " & Me![txtCASE_ID]
    
    grst.MoveFirst
    grst.FindFirst strCriteria
    
        If grst.NoMatch Then
            MsgBox "No Match was found."
        Else
            MsgBox "It worked!"
        End If

End Sub
 
The syntax appears correct... if there was a prob with data types, you'd get an error message like "Data Type mismatch in criteria expression".

The field you are referencing must also be correct, otherwise you would again get an error msg.

The 'MoveFirst' is unnecessary, but wouldn't affect the FindFirst, so no matter.

That pretty much only leaves the possibility that the id you're looking for truly doesn't exist in that table. Are you really sure you're referencing the correct table?

Max Hugen
Australia
 
how are ya KaminskiT . . .

Try:
Code:
[blue]   strCriteria = "[fld_CASE_ID] = " & Val(Me![txtCASE_ID])[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top