Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    4

    Unhappy Unanswered: Access if and then else ? I used to know this stuff :(

    Hi guys

    I have lots of buttons on my form and basically every button prints 3 reports.

    Now what I need to be able to do is to amend the code bellow so before it prints report 2 to check if checkbox called “SW” is checked and if it is then to leave out report 2 and to print "SouthWest" report instead and if it isn't then to print report2 and then report 3 after that.

    Please help i know it's only 2 extra lines but i don't know how to write them properly



    Private Sub stl_Click()

    On Error GoTo Err_stl_Click

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    Dim stlinkcriteria As String
    Dim stDocName As String



    stlinkcriteria = "[Searches]![SearchID]=" & Me![SearchID]
    stDocName = "stl1"

    DoCmd.OpenReport stDocName, , , stlinkcriteria
    stDocName = "stl2"

    DoCmd.OpenReport stDocName, , , stlinkcriteria
    stDocName = "stl3"

    DoCmd.OpenReport stDocName, , , stlinkcriteria

    Exit_stl_Click:

    Exit Sub



    Err_stl_Click:

    MsgBox Err.Description

    Resume Exit_stl_Click

    End Sub



    Thanks

    Dugi

  2. #2
    Join Date
    Nov 2003
    Location
    Sussex, England
    Posts
    404
    Dim stlinkcriteria As String
    Dim stDocName As String

    stlinkcriteria = "[Searches]![SearchID]=" & Me![SearchID]
    stDocName = "stl1"

    if me.SW=true then
    DoCmd.OpenReport "South West"
    else
    DoCmd.OpenReport "stl2"
    end if

    stDocName = "stl3"
    DoCmd.OpenReport stDocName, , , stlinkcriteria

    Exit_stl_Click:

    Exit Sub

    Err_stl_Click:

    MsgBox Err.Description

    Resume Exit_stl_Click

    end sub


    (Although I'd leave out a lot of this code anyway.)

  3. #3
    Join Date
    Apr 2004
    Posts
    4
    thanks m8
    I'll try to do it this afternoon

    cheers
    Last edited by Dugi; 10-07-04 at 10:13.

Posting Permissions

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