Setting Form's RecordSource with Macro (1 Viewer)

annt

New member
Local time
Today, 06:51
Joined
Jul 10, 2003
Messages
9
I am trying to set a form's Recordsource with a macro.

Based on the user's input on an input form, clicking a button opens a 2nd form whose recordsource is determined by in the input of the 1st form.

I have a macro that basically says, if checkbox1 value is -1, setvalue of Forms!Form.Recordsource, Expression "Query1". When I run the macro I get a type mismatch error. Even though the HELP states that Strings should be enclosed with "", I think this is what Access is erroring me on...??

What is wrong? and is there some other way I should accomplish this?

Thanks!
 

fmm

Registered User.
Local time
Today, 00:51
Joined
Mar 15, 2001
Messages
76
Here's how I accomplish the same thing.

I have a hidden, unbound text box that holds the name of teh query you want to use as the record source.

The form has a default record source.

Using the Form Load event, you can set the record source to the desired query:

Private Sub Form_Load()

Me.RecordSource = Forms![frmCallingForm]![unbDataSource]

End Sub
 

annt

New member
Local time
Today, 06:51
Joined
Jul 10, 2003
Messages
9
Thanks for the suggestion, but I can't get it to work...??? I programmed the "On Load", but then I open the form, it still opens with the old recordsource...
 

fmm

Registered User.
Local time
Today, 00:51
Joined
Mar 15, 2001
Messages
76
If you post the two forms I'll take a look at it.
 

greenfalcon

Registered User.
Local time
Yesterday, 22:51
Joined
Aug 22, 2006
Messages
34
wow fmm

I just wanted to say i was rummaging through old posts and found this topic. What a great little idea. A nice workaround to get around some limitations as i understand. Just wanted to let you know you helped someone else out!

Thanks

Jason
 

Users who are viewing this thread

Top Bottom