Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2014
    Posts
    3

    Unanswered: Only can get one roster to open

    Well I decided I'd help a friend fix her database issue. Originally it was opening all the rosters but I got it to where it opens one problem is it only opens the first one. Here's what t looks like

    Private Sub Command8_Click()
    If [ReportLookup] >= "Alpha Roster" Then
    Docmd.OpenReport "Alpha Roster", acPreview

    ElseIf [ReportLookup] <> "Arrival Report" Then
    Docmd.OpenReport "Arrival Report", acPreview

    ElseIf [ReportLookup] <> "Departure Report" Then
    Docmd.OpenReport "Departure Report", acPreview

    ElseIf [ReportLookup] <> "Duty Status Report" Then
    Docmd.OpenReport "Duty Status Report", acPreview

    If [ReportLookup] <> "Local Report" Then
    Docmd.OpenReport "Local Report", acPreview
    end if
    end sub

    It will only open alpha roster regardless where you click. I tried putting true false statements in but I think I was wrong on the dim

    Thank you all that are will to take this on w me

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if you are making string comaprisons I'd usually expect either equals (ie the two match) or not equals (the two don't match), there is no concept of wildcards in VBA

    so Im surprised at
    Code:
    If [ReportLookup] >= "Alpha Roster" Then
    Docmd.OpenReport "Alpha Roster", acPreview
    I would have expected
    Code:
    If [ReportLookup] = "Alpha Roster" Then
    Docmd.OpenReport "Alpha Roster", acPreview
    you woudl probably be better off using a select case in place of linked If statements.

    mind you the smart arse in me would probably suggest
    just opening the report, supplying repoert lookup as the value with a bit of suitable error checking to handle a missing or misepleed report


    eg
    Code:
    Private Sub Command8_Click()
    on error resume next 'effectivle no error trapping just roll over to the next statement
    Docmd.OpenReport ReportLookup, acPreview
    end sub
    or
    Code:
    Private Sub Command8_Click()
    on error resume goto OhShaggy
    Docmd.OpenReport ReportLookup, acPreview
    exit sub
    OhShaggy: msgbox 'code crapped out, looking for a report called:' & ReportLookup
    end sub
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2014
    Posts
    3
    Thank you I thought maybe there needed to be something under the private sub! I will give her this and see if it works prob won't find out till Monday. I been doing this thru text and don't have my hands on it so it's tough trying to fig it out. I got it to one but just can't get it to open the right one

Posting Permissions

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