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

    Open report (Access 2000)

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

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

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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: Open report (Access 2000)

    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
    DoCmd.OpenReport "a1", acViewPreview, , "Afid = " & Me!office
    End If

    Note that you don't have to specify "" as WhereCondition, you can just omit it.

Posting Permissions

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