how to open a specific report from a specific column in combobox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    how to open a specific report from a specific column in combobox

    I have a combobox called "cmb_FindXC " that is filtered based on the mainform selection of a race.
    fields in combobox
    Distance - txtfield - column1
    TotalLaps - numberfield - column2
    Laprace - yes/no - column3
    Racename - txtfield
    Racedate - datefield
    The 2nd column in combobox, is the Totallaps field.
    When you select a "distance" in combobox, and this distance have ie the value 5 in the Totallaps field in column 2, then it must open XCReport5;

    If you select a distance and it has ie 8 in the 2nd Totallaps column, then it must open XCReport8; etc etc etc

    I have 8 different reports called report1-8 and they must be opened depending on the value in the Totallaps column 2 of the "cmb_FindXC " combox.
    The value of the Totallaps column (1-8) may vary depending on the race, and it is therefore important that the XCReport1-8 is linked to this field when opening the report.

    The query behind the combobox is called "Rt_XCSortQ "
    (XC stands for cross-country)

    i imagine it must be something to this effect in the afterupdate event of the "cmb_FindXC "
    just need the finer details
    Code:
    If "cmb_FindXC.Column.[2] = 1 then DoCmd.OpenReport "XCReport1", acViewPreview
    elseif "cmb_FindXC.Column.[2] = 2 then DoCmd.OpenReport "XCReport2", acViewPreview
    etc etc  till you get to 8th XCreport.
    elseif "cmb_FindXC.Column.[2] = 8 then DoCmd.OpenReport "XCReport8", acViewPreview
    would a list box be easier to use in this instance?
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Code:
    Private Sub cmb_FindXC_AfterUpdate()
    If Not IsNull(Me![cmb_FindXC]) Then
      DoCmd.OpenReport "XCReport" & CStr(Me![cmb_FindXC].Column(2)), acViewPreview
    End If
    End Sub

    Comment

    Working...