Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Macros / May 2008

Tip: Looking for answers? Try searching our database.

MsgBox Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Johnny - 13 May 2008 21:11 GMT
This should be fairly simple, but never for me.  All I want to do is have my
MsgBox macro to pop up and say "No data for this report".  My macro works
fine, but I cannot figure out the code for where I need it to pop up.  

The basis is a simple form with text dates beginning and ending, plus two
drop down boxes with WorkCenter# OR ClassCode# (just basic 4 digit numbers
each).  Then there is the option to print a report based on the criteria I
select.  One report button for ClassCode# and a second button for
WorkCenter#.  If the operator fails to put in a ClassCode# (for instance),
then selects the ClassCode# report button, the macro message box should pop
up with the above statement.  How and where would I insert that macro request
into the code of the form?  I tried this, but no luck:
Private Sub Report_by_WorkCenter#_Click()
On Error GoTo Err_Report_by_WorkCenter#_Click

   Dim stDocName As String
   
   If IsNull(Me!cbxWorkCenter#) Then
   DoCmd mcrMsgBox
   Exit Sub
   End If

   stDocName = "rptMFG QC Scrap Detail by WorkCenter#"
   DoCmd.OpenReport stDocName, acPreview

Exit_Report_by_WorkCenter#_Click:
   Exit Sub

Err_Report_by_WorkCenter#_Click:
   MsgBox Err.Description
   Resume Exit_Report_by_WorkCenter#_Click
   
End Sub

Any suggestions is greatly appreciated.
Signature

Johnny

Steve Schapel - 19 May 2008 02:17 GMT
Johnny,

It is not clear why you would be doing stuff within VBA code, and then
jumping out to a macro for your mesagebox.  This type of structure
should do the trick...

   If IsNull(Me!cbxWorkCenter#) Then
      MsgBox "No ClassCode# entered"
   Else
      DoCmd.OpenReport "rptMFG QC Scrap Detail by WorkCenter#",
acViewPreview
   End If

Another thing to explore would be the No Data event of the report itself.

By the way, as an aside, it is not a good idea to use a # as part of the
name of a field or control or database object.

Signature

Steve Schapel, Microsoft Access MVP

> This should be fairly simple, but never for me.  All I want to do is have my
> MsgBox macro to pop up and say "No data for this report".  My macro works
[quoted text clipped - 31 lines]
>  
> Any suggestions is greatly appreciated.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.