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

SQL String returns no records 1

Status
Not open for further replies.

cariengon

Technical User
Mar 18, 2002
283
US
I'm running code to pull records from a table if it matches a key and a date. My code errors out if there are no records found. I can't figure out how to catch the No Match, so if it is true then it skips to the next section. It was first giving me Error 1004 (I didn't have the MoveNext or If then statement). Once I added the MoveNext/If Then, it started giving me Error 3021: No current record.

I know I'm missing something simple... Any help?? All I need to do is skip to the next section if there are no records returned in the SQL Statement...

Code:
strSQLExp = "Select * From 203_ACC_Contracts_Exp_tbl WHERE fld_ACC_Master_Record_No = " & Me!txt_MasterNo_to_Lookup & " AND fld_Exp_Year = '2003';"
Set rst = DB.OpenRecordset(strSQLExp)
rst.MoveNext
If rst.NoMatch Then
    GoTo REVTBL
End If

Thanks!
Carie
 
Try to replace this:
rst.MoveNext
If rst.NoMatch Then
By this:
If rst.BOF Or rst.EOF Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi,

Why would your field fld_Exp_Year be TEXT?
Code:
fld_Exp_Year = '2003'
Should it be
Code:
fld_Exp_Year = 2003


Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Thanks PH! That worked just dandy...

Skip - The field is a text field, so that works just fine.

Thanks for your help!
Carie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top