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

Check if query is empty but not using SQl & Recordsets?

Status
Not open for further replies.

MottoK

Technical User
Oct 18, 2006
73
GB
Hi,

I have a module which opens a simple select query called "Duplicate User IDs" and I want to check if it returns an empty recordset or not.

Ok simple enough using SQL and a recordset but I don't want to have to use these (I have my reasons!) - I want to stick to using docmd's and the like - is there anyway of doing this?

Many thanks.
 
MottoK,

Not that I'm aware of.

What are your reasons for not wanting to use a recordset?

Ed Metcalfe.

Please do not feed the trolls.....
 
isnull (dlookup ("[column name]", "[Duplicate User IDs]")) will be true if the query returns no records.

pjm
 
Hadn't thought of that. :)

Ed Metcalfe.

Please do not feed the trolls.....
 
Excellent - will give that a whirl, thanks.
 
Hi - I've tried this suggestion but I keep getting the error "You cancelled the previous operation" (I have ran through it and it is the:

If IsNull(DLookup("[User_ID]", "[Duplicate User IDs]"))
line which is causing the error.

Any suggestions? Thanks Code below:


Private Sub Check_For_New_Staff_Click()
On Error GoTo Err_Check_For_New_Staff_Click



If IsNull(DLookup("[User_ID]", "[Duplicate User IDs]")) Then

MsgBox "There are still duplicate Agent ID's - this Check will not be run"


Else

Dim stDocName As String

stDocName = "Check_For_New_Staff"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Check_For_New_Staff_Click:
Exit Sub

Err_Check_For_New_Staff_Click:
MsgBox Err.Description
Resume Exit_Check_For_New_Staff_Click


End If

End Sub
 
Sorry my fault - have sorted it.

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top