ACCESS 97 Question - Pass form name and controls between forms.
Going back in time here. An old A97 application. I have a form that can be opened by numerous forms. The user is supposed to iinput data and upon closing of the form data will requery a combobox on the source form
How do I do that? I can do it using [Forms]![frmName]![cboCtrl].requery when it is only two forms. I do not know how to do it when any forms can be opening the second form.
I tried creating two hidden textboxes on the forms and passing it back as follows:
Dim f As Form
f.Name = txtFormSource
Dim cbo As ComboBox
cbo.Name = txtObjSource
[Forms]![f]![cbo].Requery
But it does not work. How do I make proper declarations to do this?
Thanks
PBLack
Microsoft Access
Last Comment
Dale Fye
8/22/2022 - Mon
Todd MacPherson
ASKER
I also tried
Dim f As Form
f.FormName = txtFormSource
Dim cbo As ComboBox
cbo.ControlName = txtObjSource
Forms!f!cbo.Requery
Another way to do it is to open the form using the acDialog mode at the end of the OpenForm method. What this does is halt all further processing of code in the module that opens the form (until the 2nd form is closed or hidden).
Then, instead of closing the second form, just hide it (me.visible = false). This will allow the code in the original form to continue processing. During which you can refer to controls form #2. It might look like:
Private Sub cmd_OpenForm
dim somevalue as variant
docmd.openform "2ndFormName",,,,acDialog 'check the number of commas
SomeValue = forms("2ndFormName").txt_SomeField
docmd.close acform, "2ndFormName"
Dim f As Form
f.FormName = txtFormSource
Dim cbo As ComboBox
cbo.ControlName = txtObjSource
Forms!f!cbo.Requery
Does not work. Both sample throw an error at f.
Object Variable or With Block Variable Not set