How do you use a combox on single form, that will open and filter another form?

Posted on 2008-11-15
Last Modified: 2013-11-28
I used the attach code to do virtually the identical thing with a report.  Using a combobox to filter the results of a report, and I'm having no luck transferring the same concept to opening a form rather than a report.  The user would choose to enter data on a form, and seperate form with a single combobox would pop up anking for details, which would then filter out the main form.

Code I've been trying to use is below
Private Sub cboChooseOption_AfterUpdate()

    MsgBox Me!cboChooseOption.Column(0)

    MsgBox VarType(Me!cboChooseOption.Column(0))

    On Error GoTo Err_cmdFormApp_click:

    Dim FormName

    FormName = "frmAddDataForOptionChosen"

    DoCmd.OpenForm _

        FormName:=FormName, _

        Wherecondition:="[PK] = '" & Me!cboChooseOption.Column(0) & "'"


    Exit Sub


    If Err.Number = 2501 Then

    Else: MsgBox Err.Description

    End If


    GoTo Exit_cmdFormApp_Click


End Sub

Open in new window

Question by:Matt330
    LVL 75

    Accepted Solution

    Try this:
    Ii PK is Numeric

    Wherecondition:="[PK] = "  & Me.cboChooseOption.Column(0)

    If PK is a String:

    Wherecondition:="[PK] = "  & Chr(34) &  Me.cboChooseOption.Column(0) & Chr(34)


    Author Comment

    That was it - it was because PK was numeric.  Thanks again MX!  I'll figure out what all these single quote/ triple-double quotes  mean eventually.
    LVL 75

    Expert Comment

    by:DatabaseMX (Joe Anderson - Access MVP)
    you are welcome.  Chr(34) is a double quote ... used for clarity in posting.


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now