Solved

Access 2010 Message Box

Posted on 2014-10-08
4
305 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
ID: 40368277
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
ID: 40368348
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
ID: 40368360
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
ID: 40368378
Thanks -- Very Good
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

863 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

24 Experts available now in Live!

Get 1:1 Help Now