Refer to form dynamically form a module

liddlem

Registered User.
Local time
Today, 05:21
Joined
May 16, 2003
Messages
339
Hi all
I have a few forms that call a function in a module.

The call is changeaddr(me.form.name)
However in the module I want test conditions and then (if required) change values on the form that made the call.

In short, the function looks like:

Function ChangeAddr(FN as String)

If Not IsNull(Forms!FN![Property_commune_Name]) Then'
End function

The error that I get is : Cannot find the form FN

So how would I put the form name in dynamically?
 
Thanks Gizmo. The first suggestion worked a treat
 
Its hard to tell, but I think the general technique could be better.

There's nothing wrong with passing a form reference, I do that all the time.

If you create the function like below, you could call the function out of an update query and update all or any subset or records in a table.

In this situation I'd rather do something like this ...

Create a function that accepts the string, and passes back a fixed up string. Then just set the control on the form equal to the value of the function.

ex.
' do whatever you need to do in the case it's null or an empty string ...
' this code would be in the form's module
Me!txtAddress1 = funFixAddress(me!txtaddress)

then in the global module ...
function funFixAddress(EntryString as string) as string

' do whatever string manipulation you need, then set funFixAddress to your new string.

end function
 

Users who are viewing this thread

Back
Top Bottom