Carry Variable over to Open Form based on Menu Selection

Robert M

Registered User.
Local time
Today, 06:06
Joined
Jun 25, 2009
Messages
153
I have a form that, based on the selection from the Option Group in the main menu, is opened with one of 4 queries being the record source. I am able to do this, but I am also needing to carry over the values generated by the option group that are "Title" and "Mrk". Currently I am using...

Select Case Mrk
Case 1
docmd.OpenForm "DataEditSubform", acNormal, "Cycle1"
LookUp.SetFocus
Me.DataEditSubform.Form.RecordSource = "Cycle1"
Me.DataEditSubform!Title = "Current Cycle"
Me.DataEditSubform!Mrk = "1"
End Select

This is just a test code, the other three Cases will be the same with Recordsource, Title and Mrk being different.

Any help with this is greatly appreciated.

Thank you for your time and help in this matter.

Robert M
 
What version of access ?

OpenArguments can pass a value when opening a form and Public Variables can hold data the new form can use when opened.

2010 (& 2007) has TempVars that act like Public Variables but do not require to be defined.

Could you use some Code with OpenArgs to represent a selection choice for the new form but I guess this will imply some degree of Hard coding the options which shouldn't be a first choice.

If the first form remains open, you should be able to refer to controls on same when opening the 2nd form.
 
you can save these values as public variables
 
"...but I am also needing to carry over the values generated by the option group that are "Title" and "Mrk"."
Sorry, those are the field names that contents I am needing to carry over to the form I would be opening with the menu selection.

Thank you for your help vbaInet

Robert M
 
Sorry, still a bit unclear Robert. What did you mean by "generated"? Is there some sort of code run when the option group is clicked?
 
What I have are 3 groups of dates, each group must be worked individually. I have created queries that break the 3 groups of dates into their individual groups. I have one form that can be attached to any one of those queries. The Main Menu has a an Option Group that will allow the user to select which date group to work with before selecting a menu item to open that form. My problem is in coding the Menu Item to open the form with the correct query attached.

Thank you for your help with this.

Robert M
 
Problem Solved. Rather than try and carry a variable to a new form, I opened the new form and used
[Field Needing Info] = Forms![form name]![field name of what I am needing]
This does a very good job of getting me the information I am needing.

Thanks for all who helped me on this problem

Robert M
 

Users who are viewing this thread

Back
Top Bottom