setting form recordsource using a macro

paulmcdonnell

Ready to Help
Local time
Today, 09:01
Joined
Apr 11, 2001
Messages
167
Hi guys,

I'm using a macro to open a form from the tool bar, but I want to set the form recordsource in the macro. I can't quite seem to find where to put this to get it to work... Any ideas


Thanks in advance

paul
 
You can set the WHERE part of the arguments for the form in the macro. If you set the action OpenForm, the arguments appear on the bottom. FormName:, View:, WHERE:,etc.

You can use the build button next to WHERE to help build your criteria.

Is that what you were wanting?
 
Close.

I have a variable called strsource which changes the record source depending on where the user opens the form from.

I need somehow to set this strsource to the required query name or set the Recordsource property to this

I tried me.recordsource = "query1" and strsource = "query1" in the where condition but neither seem to work... any further ideas..

Thanks so far

paul
 
I was hoping you were NOT trying to alter the record source from your macro, but only looking for filtering.

As is that is NOT the case, I am at a loss to help you. I can suggest at this point only this:

If you are executing the macro from a form, you have set your variable with the code somewhere in there upon a user action/input. That variable (I'm guessing here) is only a temporary house and you need something solid to base your conditions on. Say, an unbound control, set to strsource. Your conditional macro statement would be =Forms!FormYouWereOn![UnboundControlName], the action would be to open Query1 for that line. Subsequent lines would open the other queries or whatever else you wanted to have as options.

Also, although I cannot help with this...You mightlook into the Select Case coding.
 
Thanks for the effort j

Gonna have another bash in a bit

Cheers
Paul
 
Cheers Pat...

The only thing is if I open the form from the Menubar how does the form know that it is being opened from here. I.e. opening from other forms I set a condition on the click event of the control, but setting the event from the Menu bar is slightly different isn't it...

Cheers
Paul
 

Users who are viewing this thread

Back
Top Bottom