Solved

Access 2010 Message Box

Posted on 2014-10-08
4
301 Views
Last Modified: 2014-10-08
I'm using the code below to drill down (link) to another form. I would like to pop up a message box if no records are found. Thanks

DoCmd.OpenForm "frm_Accounting_Events", , , "[Event Type]='" & Me.Event_Type & "'"
0
Comment
Question by:shieldsco
  • 2
4 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
add a dcount() to test if there are records  to show before opening the form

if dcount("*",<record source of the form>,"[Event Type]='" & Me.Event_Type & "'") =0 then
    msgbox "No records"
    exit sub
else
'open form


DoCmd.OpenForm "frm_Accounting_Events", , , "[Event Type]='" & Me.Event_Type & "'"

end if
0
 

Author Comment

by:shieldsco
Comment Utility
Error Message can' find the field referenced in the expression:

If DCount("*", ([tbl_Accounting_Events]), "[Event Class]='" & Me.Event_Class & "'") = 0 Then
     MsgBox "No records"
     Exit Sub
 Else
 'open form


 DoCmd.OpenForm "frm_Accounting_Events", , , "[Event Class]='" & Me.Event_Class & "'"

 End If
0
 
LVL 24

Expert Comment

by:Bitsqueezer
Comment Utility
Hi,

you must enclose that in double quotes:
DCount("*", "tbl_Accounting_Events", "[Event Class]='" & Me.Event_Class & "'")

Open in new window


Cheers,

Christian
0
 

Author Closing Comment

by:shieldsco
Comment Utility
Thanks -- Very Good
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now