Results 1 to 3 of 3
  1. #1
    harveya382 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jan 2013
    Posts
    2

    Passing subform keyfield value to VBA behind a button.

    As an Access newbie, I am short of knowledge being able to accomplish a programming task. and cannot find the right question to ask google for my question.
    I am trying to get a button to in a subform to use the value of the key Field in the current data row of that subform in a SQL Query. My plan is to then use the value in an update query that updates a cross reference table. My situation is I have memberships in a swim club. Members schedule swim lessons.
    The memberships have a table with a Membership# key. There is also a member table with a member# key and a membership# foreign key. There is a Lesson table with and Lesson# key, Session#, Level#, TimeSlot#.


    I have a cross reference table (memberlesson) to facilitate a many to many join between members and lessons with and autokey and the member# and Lesson # fields.
    I have a master form Membership with a Members subform displaying all the member records for a membership (mom, dad, child 1, child2, etc). I want to place a button on the row that has a member who is signing up for a lesson that updates the memberlesson table with the member# from the row that the button is on and a lesson# value determined by a query against the lesson table selecting the correct Session#, Level#, TimeSlot#. I know how to do the query to select the lesson# and to update the memberlesson able. I do not know how to get the value of the selected Member# record from the Members subform to pass into the update query.
    Can you help me? Or direct me to a resource that can help me?
    Thanks -

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Have you tried putting the button in the subform? In design view, add the button and, in the click event, add this line:
    Code:
    MsgBox "Member Number is " & Me.Member_Num
    Change to blue text to your field name.
    In normal view, click the button. Is the correct ID returned? (I hope you are not using # in the field name)

    If it is (and it should be according to my tests), add the rest of the code.

  3. #3
    harveya382 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jan 2013
    Posts
    2
    This Me. function seems to work great thanks for your quick reply. When I figure out how to mark this answered, I will.

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

Similar Threads

  1. Code for button to open new form passing value
    By cptNemo in forum Programming
    Replies: 3
    Last Post: 09-13-2012, 09:46 PM
  2. Replies: 2
    Last Post: 05-17-2012, 11:19 AM
  3. Replies: 3
    Last Post: 05-09-2012, 04:04 PM
  4. Replies: 3
    Last Post: 05-23-2011, 02:15 PM
  5. Passing focus to subform.....
    By smorelandii in forum Forms
    Replies: 3
    Last Post: 02-04-2011, 10:51 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