In "frmTransact", I wish to use the name of the calling form (frmMain):
in the first form ("frmMain"), I call the second form ('frmTransact") thus
In the second form("frmTransact"):
private aFormName as string
Private Sub Form_Open (Cancel as integer)
Dim myID as integer
aFormName = Screen.ActiveForm.name
myID = [Forms]![aFormName]!txtID.value ' (txtID is a control in the first form)
This throws an error .."cannot reference aFormName". However, "aFormName" contains the actual name of the first form ("frmMain"); it appears if you add " msgbox aFormName" to the FormOpen event of the second form.
Why do I get this error? If I use instead
myID = [Forms]![frmMain]!txtID.value
it works fine. Obviously something I don't understand about controls.
Last edited by praxis1949; 01-27-14 at 16:39.
Reason: Poor proof reading