Results 1 to 10 of 10
  1. #1
    jonillson is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    5

    Querying a Subform


    Hi,

    I have a form, card_file, with an embedded subform, card_access_point_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_point _file. Specifically, I would like the combobox to query the card_access_point_file.accesspoint_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

    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

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I am not sure the other part of syntax of form's filter, but the follow part need to be fix:
    Original:
    stLinkCriteria = "Forms!card_file!card_access_point_file.Form.a cces spoint_entry LIKE" & "'*'&" & "'" & Forms!card_file!SAPE & "'" & "&'*'"
    Revised:
    stLinkCriteria = "Forms!card_file!card_access_point_file.Form.a cces spoint_entry LIKE" & "'*" & Forms!card_file!SAPE & "*'"

  3. #3
    jonillson is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    5
    Quote Originally Posted by weekend00 View Post
    I am not sure the other part of syntax of form's filter, but the follow part need to be fix:
    Original:
    stLinkCriteria = "Forms!card_file!card_access_point_file.Form.a cces spoint_entry LIKE" & "'*'&" & "'" & Forms!card_file!SAPE & "'" & "&'*'"
    Revised:
    stLinkCriteria = "Forms!card_file!card_access_point_file.Form.a cces spoint_entry LIKE" & "'*" & Forms!card_file!SAPE & "*'"
    i have corrected this, but i'm still not having any luck.

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    So I don't think you can set a filter this way.

    are you trying to filter the sub form by the value of SAPE? if you are, you need to do follow things:
    1 set the "control source" of SAPE to a field of the source table of the main form;
    2 set up the link of main form and subform.

    Oops! No, you the link's relative can not be "like".
    you need to filter the subform by SAPE_afterUpdate event.

    in the after update event of SAPE, use following codes(not tested):
    Code:
    private sub SAPE_afterUpdate()
         card_access_point_file.filter = "access_point_entry LIKE '" & SAPE & "'"
         card_access_point_file.filterOn = true
    end sub

  5. #5
    jonillson is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    5
    Perhaps I can provide some more information.

    There are three tables involved:

    card_file
    access_point_file
    card_access_point_file

    The card_file contains three fields:

    cf_ID
    cf_heading
    cf_entry

    The access_point_file contains a few more than three, but here are the relevant fields:

    apf_ID
    apf_entry

    The card_access_point_file is an intermediary table designed to handle the many-to-many relationships between the card_file and the access_point_file. It has the following fields:

    capf_ID
    cf_ID
    apf_ID

    The database is designed to serve as a small catalog of paper index cards. An index cards look as follows:

    Heading: Clubs

    Entry: G. Morton Wolfe, president. Courier Express. Jan. 13, 1945, p.16; Jan.26 sec.4 p.9.

    I am using the the card_access_point_file to handle the multiple access points associated with each card. In the example above, the access points might be something like:

    1. Wolfe, G. Morton
    2. Clubs
    3. Courier Express

    On my main form, card_file, I would like to query access points and retrieve all entries in the card_file that are related to the access point queried. So, e.g., I'd like to query "Wolfe, G. Morton" and retrieve all entries in the card_file table that have this access point. I would also like the other access points to display.

    Perhaps this is not possible, but it seems like pretty basic functionality.

    Thanks in advance for your help.

    John

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    would please describe what is showing in the main form, the subform and in SAPE when the form open?

    Then, how will you query an access point? type then name in text box or select from SAPE or subform? and then what do you want to show in the main form and sub form and SAPE?

  7. #7
    jonillson is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    5


    I've attached a screen.

    The second cbo box, which is presently not labeled, is the one I'm working on. It has this row source:

    SELECT access_point_file.accesspoint_entry FROM access_point_file ORDER BY access_point_file.accesspoint_entry;

    Which generates a list of access points currently in use in the DB.

    (Note: I simplified my description of the tables/names involved in my description above. Here are the actual names:

    There are three tables involved:

    card_file
    access_point_file
    card_access_point_file

    The card_file contains three fields:

    cf_ID (Key)
    card_heading
    card_entry

    The access_point_file contains a few more than three, but here are the relevant fields:

    accesspoint_entry (Key)

    The card_access_point_file is an intermediary table designed to handle the many-to-many relationships between the card_file and the access_point_file. It has the following fields:

    capf_ID (Key)
    cf_ID
    accesspoint_entry

    )

  8. #8
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I am lost on what you are try to do. you mentioned you want to query an access_point, then what do you want to show in the main form and sum form.

    do you want to query like: select an access point in the not_labled_cbo_box, then show all card information in the sub form and show cards in SAPE?

  9. #9
    jonillson is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    5
    Quote Originally Posted by weekend00 View Post
    I am lost on what you are try to do. you mentioned you want to query an access_point, then what do you want to show in the main form and sum form.

    do you want to query like: select an access point in the not_labled_cbo_box, then show all card information in the sub form and show cards in SAPE?
    SAPE is the name of the unlabeled cbo_box on the main form. I want to select a value from that box and retrieve all records in the card_file table (main form) that have that associated access_point heading. I want everything you see displayed to be displayed.

    E.g., In this screen, I have selected "architects" from the list. I want to be able to click the find button and retrieve all of the records in the card_file that have this access point, "architects" in the subform.[IMG][/IMG]

  10. #10
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I am sorry but I can't see any picture because of the policy in my computer.

    So, you can put script in the after_update event of the cbo box or behind the "find" button as you said.

    try following code in the event:
    card_access_point_file.filter = "accesspoint_entry LIKE '" & SAPE & "'"
    card_access_point_file.filteron =true

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Querying a password DB
    By blacksaibot in forum Programming
    Replies: 2
    Last Post: 05-20-2010, 10:37 AM
  2. Querying a database with optuion buttons
    By MattB in forum Access
    Replies: 1
    Last Post: 01-28-2010, 06:43 PM
  3. Querying from 2 tables
    By egnaro in forum Queries
    Replies: 6
    Last Post: 01-28-2010, 06:30 PM
  4. Help Querying series
    By ktmchugh in forum Queries
    Replies: 20
    Last Post: 05-05-2009, 04:31 PM
  5. Querying Queries for Music School
    By jenny_jumps in forum Queries
    Replies: 0
    Last Post: 01-28-2009, 11:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums