PDA

View Full Version : Passing Form names



mud2
09-22-2008, 08:48 AM
I have a form, named Name_Age, with a filed called Myname. I want to "access" the data in this field in a module. The sub in the module is called Find_Remote(arg)
From the form,
I "call" Find_Remote(Me.Name) OR Find_Remote(Me.RecordSource)
In Sub Find_Remote(arg) ;
Forms.Name_Age.MyName.Value Works . (No variables)
But
Forms.arg.Myname.value Does not work, and gives the error message
"Object does not support this property or method"
So, How do I pass a form name?

CreganTur
09-22-2008, 11:05 AM
It would be easier for you to capture the value of the Form object in a variable in the code behind your Form, and then pass that variable to your Module.

Slyboots
09-22-2008, 11:06 AM
One way to do this is to pass NOTHING. Instead, put these lines into the called subroutine:

Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm

S

mud2
09-23-2008, 07:33 PM
Thank You Slyboots, it works like a charm!

Now a new one. Ive solved this before, but can't remember how!;
I add a name into a combobox that isn't in its record source. This triggers a "notInList". I then pick up that name, erect an SQL and INSERT it into the record source. Fine, so far. BUT the combo box can't find this new value until I shut down and restart! I've requeried all over the place...no luck!
By the way, ACCESS'S Help suggests just adding the new name to the recordsource, but unfortunately ACCESS, knowing all, insists on inserting a semicolon at the end of ITS record source, and adding a new name results in an error..."...added after end..."