How to select a report from a Combobox

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

    How to select a report from a Combobox

    I created a table listing all the different reports/forms and Crosstab queries i require, and wants to select the relevant reports/queries/or forms from there using the "after update" function, based on the Id field of the specific Report/Query or form in the "AllTblFinRepor ts" table where i listed it.

    When i use my vba code, it opens up all the reports/forms or queries at once.

    finreports1 is a textbox using "=[finreports].[Column](0)" from the id field in the combobox

    Code:
     If IsNull(Me![facility1]) Then
    Exit Sub
    Else
    If Me.finreports1 = "1" Then DoCmd.Minimize
    DoCmd.OpenForm "frmViewcaptTrans", acFormDS, "", "", acEdit, acNormal
    If Me.finreports1 = "2" Then DoCmd.Minimize
      DoCmd.OpenForm "frmPharmTopmedsCnt", acFormDS, "", "", acEdit, acNormal
    DoCmd.Maximize
    If Me.finreports1 = "3" Then DoCmd.Minimize
     DoCmd.OpenForm "frmPharmTopmeds2", acFormDS, "", "", acEdit, acNormal
    DoCmd.Maximize
    If Me.finreports1 = "4" Then DoCmd.Minimize
        DoCmd.SetWarnings False
        DoCmd.OpenQuery "UpdateNPITID2", acViewNormal, acEdit
        DoCmd.OpenQuery "UpdateNPITID3", acViewNormal, acEdit
        DoCmd.OpenQuery "UpdateNPITID4", acViewNormal, acEdit
        DoCmd.OpenQuery "UpdateNPITID5", acViewNormal, acEdit
        DoCmd.OpenQuery "UpdateNPITID6", acViewNormal, acEdit
        DoCmd.SetWarnings True
        DoCmd.OpenReport "rptNPConsumeSummary", acViewPreview, "", "", acNormal
      If Me.finreports1 = "5" Then DoCmd.Minimize
        DoCmd.OpenReport "rptfutureexpire", acViewPreview, "", "", acNormal
        DoCmd.Maximize
        End If
    I have tried all sorts of configurations with "elseif" and "else" and with "end if" without success.
    Any suggestions will be welcomed please
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    #2
    I am a fool - got it working by adding "end if" after each "if then" statement
    Maybe somebody else can also learn from this "oversight"

    Comment

    Working...