Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Thanked 0 Times in 0 Posts

    how to stop the code from opening a report (Access 2000)

    I want to open a report from a form only in case an option is selected from the option box called office.Nevertheless my command seems to be overlooked and the report is being opened. I also have a command in the OnOpen event of the report, which is also trigered and it shows that my command not to open the report
    is not working. Can somebody tell my why my code is wrong ?
    My command in the OnClick event of the button :

    If Forms![FBenchmark]![Office].Value = 0 Then
    MsgBox " Please select an Office ! "
    Cancel = True
    Exit Sub
    Dim stDocName As String
    stDocName = "rptOffers"
    DoCmd.OpenReport stDocName, acPreview
    End If

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Crystal Beach, FL, Florida, USA
    Thanked 33 Times in 33 Posts

    Re: how to stop the code from opening a report (Access 2000)

    The best way to debug code is to put a breakpoint at that first "If" statement. You can then show the value of any variable by passing the mouse over it. Then you can see precisely what the value of Office is. I'm betting that it is Null.

    BTW, if Office is really a yes/no field (such as a checkbox), you will be much better off in the long run if you compare it to True/False. For one thing, it makes it easier to read.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts