RenegadeAndy
RenegadeAndy

Reputation: 5690

MS Access Auto Populate form based upon a different field's selection

I have a couple of tables in my database.

workout_moves - ID, workout Type, Exercise, Reps session_moves - ID, Exercise(from workout_moves table), Weight, Notes

I have created a form called workout session which has created a subform for the session_moves table.

The session_moves subform looks like this :

enter image description here

This is fine -but when I select my exercise from the list, I want it to autopopulate the associated Reps value from the workout_moves table rather than forcing me to pick from the list, which is not quite what I would like.

As you can see in the workout_moves table, each exercise is matched to a reps column so this should be pretty easy:

enter image description here

I just cannot work out what the "Row Source" should be for the Reps column in this form in order to auto pull in the data associated with the selection in the Exercise column. Please help.

Upvotes: 0

Views: 132

Answers (1)

BitAccesser
BitAccesser

Reputation: 719

Set the control source to

=Dlookup("Reps";"workout_moves";"[workout Type] = '" & Nz(cboExercise;"") & "'")

in the Reps control. cboExercise is the controlname of the exercise combobox.

Think about changing foreignkey in table session_moves from Exercises to ID (use primarykeys as foreignkeys).

Upvotes: 1

Related Questions