I'm working on a database that was created by someone else. They used a code to open a specific form based on the value of a combobox. The code is:
The actual code is quite long.
The problem I'm running into is the form has some text boxes where I would like the values to carry over to the appropriate form that opens.
Right now I have each form individually listed out like this:
And it will open the appropriate form with the text boxes filled in which is wonderful BUT since there are so many options I just wanted to simplify the code to read something like:
But I am getting "Run-time error '2494': The action or method requires a Form Name argument.
Code:
Dim str Form As String If Me.ComboSelect.Value = "A" Then strForm = "AForm" ElseIf Me.ComboSelect.Value = "B" Then strForm = "BForm" ElseIf Me.ComboSelect.Value = "C" Then strForm = "CForm" ElseIf Me.ComboSelect.Value = "D" Then strForm = "DForm" End If DoCmd.OpenForm strForm
The problem I'm running into is the form has some text boxes where I would like the values to carry over to the appropriate form that opens.
Right now I have each form individually listed out like this:
Code:
If Me.ComboSelect.Value = "A" Then Forms!AForm.Text1.Value = Me.Text1.Value Forms!AForm.Text2.Value = Me.Text2.Value Forms!AForm.Text3.Value = Me.Text3.Value End If
Code:
DoCmd.OpenForm strForm Forms!strForm.Text1.Value = Me.Text1.Value Forms!strFormText2.Value = Me.Text2.Value Forms!strForm.Text3.Value = Me.Text3.Value
Comment