Test for No data

  • Thread starter Thread starter CJ
  • Start date Start date
C

CJ

Hi Groupies:

I am a little challenged when it comes to working with Nz so I think I'll
just save time and ask right away....

I have added functionality to archive old data to an "Archive" database.
However, I would like the user to be notified if there is no valid data to
be archived. I realize that reports have the On No Data event, but Forms do
not, and that is what I need.

In my database, when the user pushes the "archive" button, a form opens to
show them all of the records that will be archived. If there are no records,
I would like a message box to tell them so and the review is cancelled. I do
not want to use a report because the user needs to be able to double click
on a record to view more details.

How do I tell access to test for data?

Thanks in advance.
CJ
 
you must have some criteria that serves to identify the records to be
archived. you can run a DCount() function on the table or query that the
form is bound to, using the identifying criteria, and only open the form if
at least one record is returned, as

If DCount(1, "TableOrQueryName", "SomeField = somecriteria") > 0 Then
DoCmd.OpenForm "FormName"
Else
MsgBox "No records to be archived at this time."
End If

hth
 
CJ said:
I am a little challenged when it comes to working with Nz so I think I'll
just save time and ask right away....

I have added functionality to archive old data to an "Archive" database.
However, I would like the user to be notified if there is no valid data to
be archived. I realize that reports have the On No Data event, but Forms do
not, and that is what I need.

In my database, when the user pushes the "archive" button, a form opens to
show them all of the records that will be archived. If there are no records,
I would like a message box to tell them so and the review is cancelled. I do
not want to use a report because the user needs to be able to double click
on a record to view more details.

Check the form's RecordsetClone's RecordCount property:

If Me.RecordsetClone.RecordCount = 0 THen
MsgBox "No Data"
Exit Sub
End If
' archive data
 
Tina and Marshall, thank you very much for your suggestions.

Either will work and no NZ....wooohooooo!!

Thanks again
CJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top