We help IT Professionals succeed at work.

ACCESS 97 Question - Pass form name and controls between forms.

PBLack
PBLack asked
on
351 Views
Last Modified: 2012-05-11
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
Comment
Watch Question

Author

Commented:
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

CERTIFIED EXPERT
Top Expert 2016
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Dale FyeOwner, Dev-Soln LLC
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2010

Commented:
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    

Author

Commented:
perfect

Thanks!
Dale FyeOwner, Dev-Soln LLC
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2010

Commented:
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
CERTIFIED EXPERT
Top Expert 2016

Commented:
here is the logic

null & ""=""

i just did a shortcut of
nz(<string>,"")<>""
Dale FyeOwner, Dev-Soln LLC
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2010

Commented:
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 & "") <> ""

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.