Variable Reference in forms

Thinh

Registered User.
Local time
Yesterday, 22:33
Joined
Dec 20, 2006
Messages
114
The normal way to reference a form is
Forms![name of the form]!Control.value

Is there a way to use a variable for the form name?

i have a sub that is utilized by two forms and the same fields is copy to different form depending on what they select on the popup window.

Privare Sub(FormName as String)
Forms!Formname!Control.value = Forms![Bookings]!Booknr.value
..
..
end sub

anyone have the right syntax for this i know you can use Me(Variable). there should be a way to do this
 
Code:
Forms!Form("YourFormNameHere").YourControlNameHere=Forms!Bookings.Booknr

You don't need to use .value after everything. .Value is the default
 
Although you can reference a routine in another form the best way is to create a module and put your functions/Sub in there and declare it as public.

If you require to pass date between forms then you can use a global variable.

If you want to reference different forms then declare a form object as a parameter for the function/sub and pass the form to the routine.

Call the sub

mySub me

in the sub parameter list

Public sub mySub (frmForm as Form)

then to reference a control on the form within the sub

frmForm!myControl
 
Dennisk said:
Public sub mySub (frmForm as Form)

i always make a point of putting byval or byref before each module variable so that i know what i'm dealing with
 

Users who are viewing this thread

Back
Top Bottom