Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference Form by variable 1

Status
Not open for further replies.

byevjzts

Programmer
Feb 14, 2007
14
GB
Hello all, hopefully this is a nice simple one but I just cannot figure it out...

I am trying to reference and requery a form using a variable, for example

dim FormToRequery as string
FormToRequery = me.txtFormToRequery.value

[forms]!FormToRequery.requery

This obviously will not work due to the form "FormToRequery" does not exist. So how can you requery a form where the form name is a variable?

Thanks

Phill
 
forms(frmNameVariable).requery ...

--------------------
Procrastinate Now!
 
Thanks, sorry forgot to mention its a subform, so when i try

Forms("frm_MainFormName." & WhichForm).Requery

it does not work :(
 
no, that's not how you reference a subform...

a sub form in fact is just another control on your main form, so:

forms("frmName").subFormCtrlName.requery...

--------------------
Procrastinate Now!
 
Oh i yes, i knew that, its just been one of those days :)

Thanks for your help, all sorted now.
 
byevjzts . . .

Forms![purple]MainformName[/purple]![purple]SubFormName[/purple].Form.Requery

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
My actual solution for anyone else was:

dim WhichForm as string
WhichForm = Me.txtFormToRequery
Forms("frm_MAINFORM").Form(WhichForm).Requery

Buh bye :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top