PDA

View Full Version : [SOLVED] referencing a control type



MINCUS1308
08-14-2014, 06:21 AM
Need a little help.
the following results in compiler error because of the .FIELD reference
I know this is possible, I just dont know how to do it.

'oFORM' IS THE NAME OF THE FORM. SPECIFICALLY 'oFORM' IS 'UpdateForm'
'FIELD' IS THE NAME OF THE CONTROL FIELD (COMBOBOX) BEING REFERENCED ON THE FORM. SPECIFICALLY 'FIELD' IS 'FEquipmentNumber'


SUB MyCode ()
If TEST(UpdateForm, FEquipmentNumber) = False Then Exit Sub
END SUB



FUNCTION TEST(oFORM AS OBJECT, FIELD AS CONTROL)
If (oFORM.FIELD.Text = "") Then TEST = False
END FUNCTION

Thanks

Bob Phillips
08-14-2014, 06:41 AM
A sub must have a name.

What is Field?

What is OForm?

Aflatoon
08-15-2014, 03:53 AM
If you are passing FIELD as a control, you do not need to qualify it with the form:

Function TEST(FIELD As CONTROL) If (FIELD.Text = "") Then TEST = False
End Function


which is called using:

If TEST(UpdateForm.EquipmentNumber) = False Then Exit Sub

MINCUS1308
08-15-2014, 05:49 AM
Wow. Thank you.