Selecting data in linked tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have three tables with the following fields:

tblName
NameKey autonumber
Name text
ckName yes/no

tblActivity
ActivityKey autonumber
Activity text

tblNameActivity
NameKey number
ActivityKey number

The tblNameActivity links the tblName and tblActivity tables together.

I have a continuous form using the tblName table as a record source with the
three fields. In the header of the form I have a dropdown box
(cboSelectActivity) where the user selects an activity from the tblActivity
table. I also have a command button. When the user clicks on the command
button, I what to check (turn on) the ckName check boxes for the people in
the selected activity.

Can someone help with the code I need to do this? I can’t figure it out……..

Thanks in advance.
 
Try something like this on the click event of your command button:

If Me.ckname.Value = 0 Then
Me.ckname.Value = -1
Else
Me.ckname.Value = 0
End If

That will toggle the chkbutton on & off whenever you click your button.
 
I would suggest an Update query you can run from the command button. The
query will need ActivityKey and NameKey from tblNameActivity and NameKey and
ckName from tblName. They will, of course be joined on Name Key. Filter the
query based on the value in your combo box and update the ckName field.
Notice I did not include anything from tblActivty. That is to minimize the
data you need to pull in your query. I would suggest your combo be a 2
column query where one column is ActivityKey and the other is Activity. That
way, your user will see only the Activity, but your query can filter using
the key.
 
Back
Top