Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Columbia, MO

    Unanswered: problems with VB Code opening a form based on a selection of a combo box.

    I have a problem that I can't quite understand. I have a form that has several combo boxes. When the user clicks the OK button, a form opens based upon which company is selected in one of the combo boxes. When I open the form the regular way, it works like a dream. It opens the right form every time. HOWEVER, when I open it through the switchboard, select the values and click OK, I get an error that says,

    "Runtime Error '2497':
    The action or method requires a Report Name argument."

    Here is the code I have so far.

    Private Sub OK_Click()
    DoCmd.OpenQuery "qryDeltblCoCompCarcassTemp"
    DoCmd.OpenQuery "qryAppCoCompFromCarWithToKillLocAndDate"
    DoCmd.RunMacro "mcrfrmCoComp.OK"
    DoCmd.OpenReport (ReportName.Value), acViewPreview

    When I hit Debug, the last line is highlighted.

    The ReportName comes from a query that ties the combo box company selection with a table that has the report name in a field.

    Any suggestions on how to get it to work through the switchboard would be greatly appreciated.



  2. #2
    Join Date
    Dec 2001
    I don't think Access understands what your "ReportName" variable is.

    You might want to try using the DLookup function to find your report name from the query or table.

    Hope this helps,
    Peter De Baets
    Peter's Software - Microsoft Access Tools for Developers

  3. #3
    Join Date
    Jan 2003
    Columbia, MO
    That worked great. Thanks for the help.

Posting Permissions

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