Link to home
Create AccountLog in
Avatar of Todd MacPherson
Todd MacPhersonFlag 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

But it does not work. How do I make proper declarations to do this?


Avatar of Todd MacPherson
Todd MacPherson
Flag of Canada image


I also tried

Dim f As Form
f.FormName = txtFormSource
Dim cbo As ComboBox
cbo.ControlName = txtObjSource

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

Object Variable or With Block Variable Not set

Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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.Value = SomeValue

End Sub    



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.

here is the logic

null & ""=""

i just did a shortcut of
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 & "") <> ""