• Open report (Access 2000)

    Author
    Topic
    #416271

    I have a command button in my form to open the report.
    If i write one line, for example
    DoCmd.OpenReport “a1”, acViewPreview, , “Afid = ” & Me.office
    Then the report is opened.
    However, if i write the following ElseIf condition:

    If Me!office = True Then
    DoCmd.OpenReport “a1”, acViewPreview, , “Afid = ” & Me.office
    ElseIf Me!office = False Then
    DoCmd.OpenReport “a1”, acPreview, , “”
    End If

    Then nothing happens after the click. What happens with my command?

    Viewing 0 reply threads
    Author
    Replies
    • #930748

      If Office is the option group from the database posted last night, its value is the option value of the selected radio button, not True.

      If you set a Default Value for Office, it will always have a value, so you needn’t use an If … Then … Else construction. If you haven’t set a Default Value, nothing will be selected initially. If the user doesn’t click any of the radio buttons, the option group will be Null, so you can use

      If IsNull(Me!Office) Then
      DoCmd.OpenReport “a1”, acViewPreview
      Else
      DoCmd.OpenReport “a1”, acViewPreview, , “Afid = ” & Me!office
      End If

      Note that you don’t have to specify “” as WhereCondition, you can just omit it.

    Viewing 0 reply threads
    Reply To: Open report (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: