Open certain forms based on cbo value (1 Viewer)

Zydeceltico

Registered User.
Local time
Today, 02:34
Joined
Dec 5, 2017
Messages
843
Hi all -

I have a form with a combo box.

Given the user making certain selections from the combo box I would like a prompt to open another form with out closing the current form and returning to the original form to continue entering data after the second form has been completed and closed w/ saving. By the way both forms are bound to different tables if it matters.

What is the general approach to accomplish this?

I'm thinking it would be something like:

Make a selection in combo box and put an "If cbo value = this and such then open another form" on the AfterUpdate of the cbo.

Does that sound generally like an approach that will work?

I'm not sure about the closing of the second form and returning to the first form.

Thanks,

Tim
 

June7

AWF VIP
Local time
Yesterday, 22:34
Joined
Mar 9, 2014
Messages
5,466
Yes, it does. Open form with acDialog to suspend code execution in calling form. It will resume when the second form closes.

DoCmd.OpenForm "second form name", , , , , acDialog

What is purpose of opening second form while editing on the first form?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:34
Joined
Oct 29, 2018
Messages
21,454
Hi Tim. Just a little caveat... If you leave the first form to go to the second form, any data entry on the first form will be automatically saved by Access to the bound table. If you have any data validations at this point, it might fail and stop you from opening the second form.
 

June7

AWF VIP
Local time
Yesterday, 22:34
Joined
Mar 9, 2014
Messages
5,466
I just did a test. BeforeUpdate does not execute. Record on first form is still in edit mode when the second form closes.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:34
Joined
Oct 29, 2018
Messages
21,454
I just did a test. BeforeUpdate does not execute. Record on first form is still in edit mode when the second form closes.
Hi. Thanks for letting us know. I couldn't remember all the exceptions. Cheers!
 

essaytee

Need a good one-liner.
Local time
Today, 16:34
Joined
Oct 20, 2008
Messages
512
Depending upon what you want to achieve, if you want to reference your second form on return to your first form, that is possible. While in the second form you set the form to SecondForm.Visble = False, that hides the form and you are returned to the first form. At this point you can then reference any control in the second form. Then you close the second form from the first form.
 

Zydeceltico

Registered User.
Local time
Today, 02:34
Joined
Dec 5, 2017
Messages
843
Hi Everybody - and thanks!

The reason I want to see if I am able to do this is because we have a general work process (Line Stop) that happens for several different very unrelated reasons. Each one of those unrelated conditions has its own set of characteristics to measure and record.

There are at least 3 different conditions I can think of where I would want to record data that each are best represented by 3 very different tables.

But Line Stop remains the overarching umbrella.
 

Mark_

Longboard on the internet
Local time
Yesterday, 23:34
Joined
Sep 12, 2017
Messages
2,111
Alternate approach.

Have a "tab" control that is hidden. It has unbound fields for each of your child records' fields. Based on the combo, you unhide the proper controls.

This way your users can't add a child unless they actually save the parent. Also allows you to avoid issues if they start entering one type of stop but realize they are filling in the wrong one.
 

Mark_

Longboard on the internet
Local time
Yesterday, 23:34
Joined
Sep 12, 2017
Messages
2,111
Here is a little sample.
In effect, you toss a TAB control on your form.
On each page, you have the fields you will need to add to each child table.
You set each page to .visible=false
You set the page you want to .visible=true after they have selected the proper value from your cbo.

Once you get ready to save, you check the value in your cbo and add the proper child record.
 

Attachments

  • Tabs.mdb
    232 KB · Views: 41

Zydeceltico

Registered User.
Local time
Today, 02:34
Joined
Dec 5, 2017
Messages
843
Depending upon what you want to achieve, if you want to reference your second form on return to your first form, that is possible. While in the second form you set the form to SecondForm.Visble = False, that hides the form and you are returned to the first form. At this point you can then reference any control in the second form. Then you close the second form from the first form.

That's a neat trick. Very useful. Thank you.
 

Zydeceltico

Registered User.
Local time
Today, 02:34
Joined
Dec 5, 2017
Messages
843
Here is a little sample.
In effect, you toss a TAB control on your form.
On each page, you have the fields you will need to add to each child table.
You set each page to .visible=false
You set the page you want to .visible=true after they have selected the proper value from your cbo.

Once you get ready to save, you check the value in your cbo and add the proper child record.

Thanks! Works a treat
 

Users who are viewing this thread

Top Bottom