IF...AND...THEN statements in ACCESS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • piskey
    New Member
    • Mar 2007
    • 3

    IF...AND...THEN statements in ACCESS

    Hi everyone

    i cannot figure out how to use the IF..AND...THEN statements.

    i have built a report genorater form and one of the slections is to sort a specific reports by either one fo two criteria. i have built two reports and one for each criteria and i am using the code

    If [Chckob] = True And [Opt_dep] = true Then
    DoCmd.OpenRepor t "Obstacle Card Comments", acViewPreview, , obwh
    End If

    one being a check box and one being an option button

    which i was hoping it would do but i get a debug error of "you have entered a expression with no value"

    can someone please advise what i am doing wrong please
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Hi there is no need to use the square brackets in your statement:
    Code:
    If Chckob = True And Opt_dep = true Then
        DoCmd.OpenReport "Obstacle Card Comments", acViewPreview, , obwh
    End If
    You can also write it like this:
    Code:
    If Chckob And Opt_dep Then
        DoCmd.OpenReport "Obstacle Card Comments", acViewPreview, , obwh
    End If

    Comment

    Working...