Full Version: HasData for Forms?
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
dashiellx2000
I have a form (single) where the user enters their search criteria and then opens another form (Continuous) where they mark if a request was completed or rejected. Is there a way I can check to see if this second form has data before it is opened. I know HasData is only for reports, but I was wondering if they have anything similar for forms.

Thanks.
Larry Larsen
Hi
Try this on the open event:
CODE
If Me.RecordsetClone.RecordCount = 0 Then

        MsgBox "No records for that parameter", vbInformation + vbOKOnly, "No records"

        Cancel = True

    End If

thumbup.gif
dashiellx2000
Thanks Larry. That works from keeping the second form from opening. However, now I'm getting a Run Time 2501 error on the first form's button Onclick event. I'm assuming it has to do with the code I'm using to open the second form:
QUOTE
DoCmd.OpenForm "sfrmProcessWriteoffRequests", , "", "", acFormPropertySettings


Can you see what I'm doing wrong?

Thanks.
Larry Larsen
Hi
Just puzzled as to why you have quotes in the two arguments (filtername,wherecondition)
thumbup.gif
dashiellx2000
I realized my mistake (I was still working in the second form's OnActivate event rather then the onOpen event.

Actually, I did get rid of those quotes, however, I was under the impression that if you weren't using arguments, but were using latter arguments in the string, you had to put "" in there for it to pass through. From your question, I'm assuming this is not the case.

Thanks.

William.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.