How do I query a subform from a cbo?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • John Havens
    New Member
    • Nov 2010
    • 1

    How do I query a subform from a cbo?

    Hi,

    I'm using MS Access 2007.

    I have a form, card_file, with an embedded subform, card_access_poi nt_file.

    I would like to create a combobox on the main form to query the card_file on values in a field on the card_access_poi nt _file. Specifically, I would like the combobox to query the card_access_poi nt_file.accessp oint_entry field.

    I have tried to do this as follows, where SAPE is the name of the cbo box, but I'm doing something--possibly many things--wrong.

    Any help you can provide is greatly appreciated.

    John

    Code:
    Private Sub SAPE_Button_Click()
    
    Dim stDocName As String
    Dim stLinkCriteria As String
    
    stDocName = "card_file"
    stLinkCriteria = "Forms!card_file!card_access_point_file.Form.acces spoint_entry LIKE" & "'*" & Forms!card_file!SAPE & "*'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    Exit_SAPE_Button_Click:
    Exit Sub
    
    Err_SAPE_Button_Click:
    MsgBox Err.Description
    Resume Exit_SAPE_Button_Click
    
    End Sub
    Last edited by NeoPa; Nov 19 '10, 06:34 PM. Reason: Please use CODE tags
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    This sounds like you could benefit from reading Example Filtering on a Form, and also, possibly, Referring to Items on a Sub-Form.

    Comment

    Working...