Selection Form confilicts with on no Data

F

Frank Situmorang

Hello,

I have a selection form of those who have birthday and then from that by
clicking the button the report will show up but I Put the on No data of the
report and then there is still debugging.

anyone can help me please?, this is my VBA:
Private Sub Command4_Click()
DoCmd.OpenReport "BukuAngKbyQuery_DepSS", acViewPreview
End Sub

Private Sub Report_NoData(Cancel As Integer)
MsgBox "Maaf, Data dimaksud tidak ada..he.he.he.!!!!."
Cancel = True
End Sub

Thanks in advance
 
K

Klatuu

Even when you cancel the report in the No Date event, you have to trap for
error 2501 in the calling form:

Private Sub Command4_Click()

On Error GoTo ErrCommand14

DoCmd.OpenReport "BukuAngKbyQuery_DepSS", acViewPreview

ErrExit:
Exit Sub
ErrCommand14:
If Err.Number <> 2501 Then
MsgBox Err.Number & " " & Err.Description
End If
GoTo Err.Exit
End Sub
 
F

Frank Situmorang

Thanks for your quick response Klatuu.

When I enter your suggestion VBA, it is with red color in the GoTo Err.Exit.

Anything wrong in the syntax?

I appreciate your help
 
F

Frank Situmorang

OK Klatuu, thanks very much it's okey now, I just delete the dot on GoTo
Err.Exit

Again thanks very much, you are awesome
 
K

Klatuu

Glad I could help, Frank.
Sorry about the syntax error. Sometimes my fingers automatically put in a
dot when I type an object name.
 

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

Top