PC Review


Reply
Thread Tools Rate Thread

Closing a report during OnOpen

 
 
jhmosow@gmail.com
Guest
Posts: n/a
 
      3rd May 2006
I have a report with the following code:

Private Sub Report_Open(Cancel As Integer)

Dim DB_Version As Variant
Dim DocName As String
Dim LinkCriteria As String

On Error Resume Next

DB_Version = DLookup("OptionValue", "Option", "OptionName =
'DefaultDatabaseLevel'")
DB_Version = InputBox("Enter database level", , DB_Version)
If IsEmpty(DB_Version) = "" Or Len(DB_Version) = 0 Then
MsgBox "Cancel pressed"
DoCmd.Close acReport, "Product Listing By Database", acSaveNo
DocName = "Inquiries/Reports Menu"
DoCmd.OpenForm DocName, , , LinkCriteria
Exit Sub
End If
Me.ServerFilter = "Database_Version = " & DB_Version
DoCmd.RunMacro "ReportToolbarShow"

End Sub

What is happening is when Cancel is pressed in the Inputbox, this does
get trapped and processes the If statement. But the DoCmd.Close does
not close the report. If Cancel is selected in the Inputbox, I want to
stop all processing of this report and go back to my menu. Any idea
what I am doing wrong or how to code this? I am using Access 2003 and
this is an ADP.

TIA

 
Reply With Quote
 
 
 
 
=?Utf-8?B?c2FsZXg=?=
Guest
Posts: n/a
 
      4th May 2006
Use the "cancel" parameter ! Report will be open only if 'cancel' remains True.

bla.. bla..
if ....
cancel=False 'here your report will be close
end if


 
Reply With Quote
 
jhmosow@gmail.com
Guest
Posts: n/a
 
      4th May 2006
That was the magic. Thx.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Reconcile Two OnOpen Conditions in a Report? Telesphore Microsoft Access Reports 0 24th Apr 2010 09:01 PM
OnOpen event fails to fire when Report opened from VBA code Peter Fletcher Microsoft Access Reports 0 9th Feb 2010 10:08 PM
Build Where Clause in OnOpen of Report Nick X Microsoft Access VBA Modules 2 7th May 2009 03:20 PM
Pop-up dialog from Report OnOpen Event =?Utf-8?B?WmlsbGE=?= Microsoft Access Reports 1 25th Apr 2006 04:14 PM
Getting the OnOpen Event of a Report to Open A Form =?Utf-8?B?QW5keQ==?= Microsoft Access Reports 2 14th Jun 2005 03:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:49 AM.