Macro to display selected data only (1 Viewer)

Megacitizen

Registered User.
Local time
, 20:18
Joined
Mar 22, 2012
Messages
130
I have a form that records the stats of teams working in one particular city in the world. The form displays the Base where the team comes from and the nation where that base is located. It also displays the region of the city where they will be concentrating.

I want to create a macro (or command button if deemed more suitable) which when clicked, will open up a 2nd form displaying the names and nationalities of all the individuals, selected from my TeamMembers table, making up the team in question. (Nationalities of individuals do not necessarily have to match the Base locations.) Ideally, this 2nd form can then be closed without the main form also closing.

Where is the best place to start?

I am working in A2007 - upgraded from an A2000 program
 

AccessMSSQL

Seasoned Programmer-ette
Local time
, 20:18
Joined
May 3, 2012
Messages
636
How do you have your Team and TeamMembers tables relationships set up?

Create the button on the main form and use VBA code. Add an OnClick event to the button.

Use this code:

DoCmd.OpenForm "frmTeamMembers", , , "TeamID = " & Me.TeamID

The 4th argument is the WHERE clause. It will filter your 2nd form by this filter.


http://www.accessmssql.com/
 
Last edited:

Megacitizen

Registered User.
Local time
, 20:18
Joined
Mar 22, 2012
Messages
130
Thanks for that. Will give it a test once I have solved another issue involving blank forms.

I was thinking of getting the Command button to run a query to get the info in my subform. The Query Builder invites me to choose numerous actions. 'Open Form' from 'Form Commands' and 'Run Query' from 'Miscellaneous' are seperate options, not sure which would take precedence. Whichever, I take it there would be no change to the code in the OnClick event.
 

Users who are viewing this thread

Top Bottom