Setting Form's RecordSource with Macro

annt

New member
Local time
Today, 20:15
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!
 
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
 
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...
 
If you post the two forms I'll take a look at it.
 
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

Back
Top Bottom