Results 1 to 4 of 4
  1. #1
    Join Date
    May 2008
    Posts
    2

    Unanswered: Combo Box Filtering between Forms

    Hello,

    I have a combo box (populated via query). I want to be able to make a choice in this then click a button. This would have the action of opening another form which has been filtered to show only records associated with this record.

    I've tried the way I think but I keep getting requests for 'parameters'

    Here is what I currently have:


    On frmMain I have a combo box which is populated with contents of query:

    SELECT [qryUnloggedRFW].[doc_number] FROM qryUnloggedRFW ORDER BY [doc_number];

    I then have this piece of VBA code:

    Private Sub Combo151_AfterUpdate()
    DoCmd.OpenForm "frmRFWNewForm", , , "[doc_number] = " & Me.Combo151
    End Sub

    Then on the second from I have the Record Source set as:

    SELECT *
    FROM tbl_management
    WHERE ((([tbl_management].[doc_number])=[forms]![frmMain]![Combo151]));

    Neither method works. I click the combo box it just keeps asking for several parameters (strangely its asking the contents on the combo box). I click the button to open the new form it still asks for one parameters

    Any help much appreciated.

    Thanks.

  2. #2
    Join Date
    Apr 2008
    Location
    All over, Now in Missouri
    Posts
    73
    This is what I do! A query displays info in the cbo box, then I put a GO button under the cbo box and coded it to the task I want to do.

    Private Sub cmdOpenrpt_Click()

    Dim stDocName As String
    Dim stLinkCriteria As String

    strcbolist = [cboreports1]

    Select Case strcbolist
    Case "Roster - Master (With SSN)"
    stDocName = "frmpopup_Sel_Roster"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Case "Roster - Master (Without SSN)"
    stDocName = "frmpopup_Sel_Roster"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    End Select

    End Sub
    We tend to look at Linear paths which can lead us to a path of resistance!

  3. #3
    Join Date
    Mar 2009
    Location
    Gatineau, Quebec Canada
    Posts
    147
    Provided Answers: 1

    Reference of Form in Query

    You can reference a control from the first form in a query (under "criteria") underlying the second form thus:

    [forms]![frmChoice]![cboclass].[value]

    where cboclass is a combobox loaded with a value list, or with a value (such as an ID number) and a name ( "bolts") drawn from the database (i.e. "Select ID, classtype....."). No filter or criteria is required for the second form -- you are automatically modifying the underlying query.

    Hopefully this is helpful.

    John Smith
    Nanning, China

  4. #4
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking

    Quote Originally Posted by andrew_ww View Post
    Hello,

    I have a combo box (populated via query). I want to be able to make a choice in this then click a button. This would have the action of opening another form which has been filtered to show only records associated with this record.

    I've tried the way I think but I keep getting requests for 'parameters'

    Here is what I currently have:


    On frmMain I have a combo box which is populated with contents of query:

    SELECT [qryUnloggedRFW].[doc_number] FROM qryUnloggedRFW ORDER BY [doc_number];

    I then have this piece of VBA code:

    Private Sub Combo151_AfterUpdate()
    DoCmd.OpenForm "frmRFWNewForm", , , "[doc_number] = " & Me.Combo151
    End Sub

    Then on the second from I have the Record Source set as:

    SELECT *
    FROM tbl_management
    WHERE ((([tbl_management].[doc_number])=[forms]![frmMain]![Combo151]));

    Neither method works. I click the combo box it just keeps asking for several parameters (strangely its asking the contents on the combo box). I click the button to open the new form it still asks for one parameters

    Any help much appreciated.

    Thanks.
    Good morning,

    Here is what I have for my database as I have the ComboBox that has all of the choices available and then after Clicking on my choice I have a CommandButton that pulls up the information in a Report. Also I have another one that as soon as you click your choice in the ComboBox, it automatically opens the Form/Report without the need for clicking anything else. I like that one better. But here is the one that works the way you described, IF I understood your situation correctly:
    Code:
    Private Sub cmbOpenTestInventoryRpt_Click()
    On Error GoTo Err_cmbOpenTestInventoryRpt_Click
    
        Dim stDocName As String
        Dim stLinkCriteria As String
        
        stDocName = "TEST Inventory Dialog"
        
        stLinkCriteria = "[Category]= " & "'" & Me![Category] & "'"
        DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
        
    
    Exit_cmbOpenTestInventoryRpt_Click:
        Exit Sub
    
    Err_cmbOpenTestInventoryRpt_Click:
        MsgBox Err.Description
        Resume Exit_cmbOpenTestInventoryRpt_Click
        
    End Sub
    Have a nice one
    Bud

Posting Permissions

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