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

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

Who is Participating?
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
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)

Matt330Author Commented:
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.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
you are welcome.  Chr(34) is a double quote ... used for clarity in posting.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.