View Full Version : Setting Form's RecordSource with Macro


annt
07-28-2003, 10:54 AM
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
07-28-2003, 12:01 PM
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
07-29-2003, 08:24 AM
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
07-29-2003, 08:25 AM
If you post the two forms I'll take a look at it.

greenfalcon
10-08-2006, 08:25 PM
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