Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Posts
    19

    Unanswered: Easy for some - linking

    I am pretty new to Access and ran into something I know is possible but can't seem to figure out. I may have everything set up completely wrong, but thats OK...let me know.

    BACKGROUND

    I have several tables with forms for each

    All tables have a field for "Program Names".

    The master table as I imagine it contains all the "Program Names"

    Other tables may or may not contain all the program names

    All tables have Program Names as the Primary Key (no duplicates)

    I set up relationships from each table to the master table


    GOALS

    I set up a form with command buttons so a user can open the form he wants. On this form is a combo box with all the Program Names from what I call the master form.

    As a user calls each form, how do I take him to the record he selected. Currently it always takes me to record #1.

    Your help is much appreciated.

    I am learning, so hopefully eventually I will be able to give answers to other people's questions.

    Thank you,
    Samandus

  2. #2
    Join Date
    Jul 2003
    Posts
    3
    I think what you need is a bit of code like this:

    Private Sub Command14_Click()
    On Error GoTo Err_Command14_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "the_name_of_the_form_you_want_to_open_here"

    stLinkCriteria = "[the_name_of_the_field_to_match_here]=" & Me![Your_combo_name_here]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Exit_Command14_Click:
    Exit Sub

    Err_Command14_Click:
    MsgBox Err.Description
    Resume Exit_Command14_Click

    End Sub

    Ok. that might look a bit daunting at first but its not too hard to understand. So on your combo box go to its properties and create an event procedure on the afterupdate event. Then type in the above code replacing 'Command14_Click' with the whatever yours is called. eg if u called your combo box 'mycombo' then you wold replace 'Command14_Click' with 'mycombo_afterupdate'.

    This code opens up a form called the_name_of_the_form_you_want_to_open_here and uses a filter to bring up the selected criteria

    good luck!

  3. #3
    Join Date
    Jul 2003
    Posts
    3
    so u've got this:

    stLinkCriteria = "[Program_names.Name_of_Program]=" & Me![Combo4]

    what would work is this:

    stLinkCriteria = "[Name of Program]=" & Me![Combo4]

    however, it will only work if u r dealing with a bound form. If you do this when the next form opens, after some one has selected a value from combo4, if you look at the form in design view and go to the form's properties you'll see that the filter attribute will have [Name of Program]= <whatever> where <whatever> wil be the value of the combo box.

    Hope this makes sense

Posting Permissions

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