Avatar of Todd MacPherson
Todd MacPherson
Flag for Canada asked on

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

Avatar of undefined
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

Does not work. Both sample throw an error at f.

Object Variable or With Block Variable Not set

ASKER CERTIFIED SOLUTION
Rey Obrero (Capricorn1)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Dale Fye

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"

    me.cbo_SomeCombo.Requery
    me.cbo_SomeCombo.Value = SomeValue

End Sub    

Todd MacPherson

ASKER
perfect

Thanks!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Dale Fye

Capricorn1,

I've asked this before, but never got an answer.  What does the following syntax represent?

if me.openargs &""<>"" 

I've never seen that ""<>"" except in some of your posts and am really interested in its meaning, and where you found that syntax.

Dale
Rey Obrero (Capricorn1)

here is the logic

null & ""=""

i just did a shortcut of
nz(<string>,"")<>""
Dale Fye

LOL!  I must be having a brain cramp!

I wasn't paying attention to the precedence of operators and was trying to figure out the significance of:

"" <> "", which is obviously False.

I usually put the

Something & ""

inside parenthesis

(something & "") <> ""

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.