How to manipulate data based on the results in a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello...

I need help. Based on the results of a query..I want to have 1 of 2 things
happen.

--If the query returns no data, I want to have a message box pop up and then
an update query executed.

--If the query brings up data, I want to have it bring up another select
query showing results.

Is this possible? How would I do this?

Thank you,
MN
 
First run your query as a recordset and check the RecordCount property. If
it's 0, do one thing, otherwise do something else. Like this:

Dim rstData As Recordset, RecQty as Long

Set rstData = CurrentDb.OpenRecordset("MyQuery",dbOpenDynaset)
RecQty = rstData.RecordCount
rstData.Close
If RecQty = 0
Do something here
Else
DoCmd.OpenQuery "MyQuery", acViewPreview, acReadOnly
End If

Sam
 
Back
Top