Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Location
    Massachusetts
    Posts
    16

    Question Unanswered: query parameters from combo box

    Hi

    I have a combo box of single column with nine entries and runs a very complicated query when user clicks one of the entries.
    Each entry creates it's own EXCEL spreadsheet.
    Works just fine, sample of WHERE clause below:

    WHERE (((AcctDivName)=([FORMS]!frmGetDiv![comboDivNbr])) AND
    ((WEEKENDINGDATE)>=FiscalCalendar.Daterange1) And
    ((WEEKENDINGDATE)<=FiscalCalendar.DateRange2) And ((FISCALCALENDAR.FISCALMONTH)=1) AND
    (((MGRID)<>"XXXXXXX")) And
    (SUPPORT.PROJECTNUM = IMPORT.PROJECTNUM AND ProjectId=GROUPCODE))
    GROUP BY ProductSeq, ProductName

    Of course, user now wants to run all the entries in the combo box from a single click on the form creating nine EXCEL spreadsheets.

    How would I code this to pass each of the comboDivNbr values to a slightly modified query when the user clicks on a RUNALLBUTTON button that is on same FORM???

    What I currently have that works fine by clicking on combo box value:


    Private Sub comboDiv_Click()

    Dim stDocName As String

    stDocName = "QRYXXXXX"
    stReport = ("test.xls")

    DoCmd.OutputTo acOutputQuery, stDocName, acFormatXLS, stReport

    End Sub


    Private Sub RUNALLBUTTON_Click()

    Dim stDocName As String

    stDocName = "QRYCLONED"
    stReport = ("test.xls")

    DoCmd.OutputTo acOutputQuery, stDocName, acFormatXLS, stReport

    End Sub


    I guess my question is how to treat this like subscripting and pass it to the query? ([FORMS]!frmGetDiv!comboDivNbr(intNbr)])) ?? Or something else?

    Any help appreciated

  2. #2
    Join Date
    Feb 2004
    Posts
    25

    RunAll

    How about in the RunAll event:
    1. set combo to first value, then call after update.
    2. set combo to second value, then call after update
    etc...

  3. #3
    Join Date
    Mar 2004
    Location
    Berlin, Germany
    Posts
    107
    just a proposal
    1. replace the [FORMS]!frmGetDiv![comboDivNbr] with a parameter
    2. put your comboDiv_Click code into a sub with the param DivNbr. set the querys parameter to DivNbr
    3. call the sub from within the RUNALLBUTTON_Click() event too using
    for i = 1 to comboDivNbr.ListCount
    >subname< comboDivNbr.Column(i-1,>DataRow<)
    next

Posting Permissions

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