Forms with Different data sources (1 Viewer)

paulmcdonnell

Ready to Help
Local time
Today, 07:38
Joined
Apr 11, 2001
Messages
167
Hi Guys,

I'm having trouble using one form for several data sources (tables). I want to use the click of a button from a control form to nominate the data source when to form is opened - but can't seem to get it right.

Do you include the table ref in the "Openform" expression to open the form or can the Record Source be set to a variable?

Either way, if you can help you may need to be a little explicit because I am fairly new to the game...

LOADS OF THANKS
PAUL
 

charityg

Registered User.
Local time
Today, 07:38
Joined
Apr 17, 2001
Messages
634
Yes you can set the recordsource equal to a string variable.

The recordsource property must be set in the onOpen event of the form.

So from the control form, you would have something like

cmdOpenForm_onclick
if blah blah then
strSource="select * from yada yada where this and that"
else
strSource="select * form yada yada where that and that and that."
endif

declare strSource as a global variable (in a module)

then in the OnOpen event of the form use
me.recordsource=strsource

should work. Let me know if it doesn't
~Charity
 

Users who are viewing this thread

Top Bottom