Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access 2010 Message Box

Posted on 2014-10-08
4
Medium Priority
?
334 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

972 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