P
pm4698 via AccessMonster.com
Hello there,
I need to push a button and have a msgBox from which i will have 4 options
(each option with a label and a checkbox).
Each option corresponds to a different form.
When i will choose an option (checkbox) then the selected form's name will be
saved at a string variable. Then i will use this string to open the selected
form with code:
docmd.openform "string_variable"
A piece of code that i tried to write is:
'public strInput As String 'Is used to save the form's name
Private button_name_Click()
Dim strInput1 As CheckBox 'Choose frm1
Dim strInput2 As CheckBox 'Choose frm2
Dim strInput3 As CheckBox 'Choose frm3
Dim strInput4 As CheckBox 'Choose frm4
Dim strMsg As String
Beep
strMsg = "Please choose which form to open..."
MsgBox "Form1" & vbCrLf & vbLf & strInput1 & _
"Form2" & vbCrLf & vbLf & strInput2 & _
"Form3" & vbCrLf & vbLf & strInput3 & _
"Form4" & vbCrLf & vbLf & strInput4 & _
"", _
vbInformation, "Choose form..."
strInput = InputBox(Prompt:=strMsg, title:="Choose form")
if me.strInput1.value= true then
strInput = "frm1 & "'"
else if me.strInput2.value= true then
strInput = "frm2 & "'"
else if me.strInput3.value= true then
strInput = "frm3 & "'"
else if me.strInput4.value= true then
strInput = "frm4 & "'"
end if
end if
end if
end if
end sub
So, when i choose a form from the msgbox, the name of the form that i chose,
is saved to strInput.
Then to open the form, i choise i will write:
DoCmd.OpenForm "strInput", , , , , ,
Can i do this?
If yes, could you give me some corrections to the code?
Thanks in advance
I need to push a button and have a msgBox from which i will have 4 options
(each option with a label and a checkbox).
Each option corresponds to a different form.
When i will choose an option (checkbox) then the selected form's name will be
saved at a string variable. Then i will use this string to open the selected
form with code:
docmd.openform "string_variable"
A piece of code that i tried to write is:
'public strInput As String 'Is used to save the form's name
Private button_name_Click()
Dim strInput1 As CheckBox 'Choose frm1
Dim strInput2 As CheckBox 'Choose frm2
Dim strInput3 As CheckBox 'Choose frm3
Dim strInput4 As CheckBox 'Choose frm4
Dim strMsg As String
Beep
strMsg = "Please choose which form to open..."
MsgBox "Form1" & vbCrLf & vbLf & strInput1 & _
"Form2" & vbCrLf & vbLf & strInput2 & _
"Form3" & vbCrLf & vbLf & strInput3 & _
"Form4" & vbCrLf & vbLf & strInput4 & _
"", _
vbInformation, "Choose form..."
strInput = InputBox(Prompt:=strMsg, title:="Choose form")
if me.strInput1.value= true then
strInput = "frm1 & "'"
else if me.strInput2.value= true then
strInput = "frm2 & "'"
else if me.strInput3.value= true then
strInput = "frm3 & "'"
else if me.strInput4.value= true then
strInput = "frm4 & "'"
end if
end if
end if
end if
end sub
So, when i choose a form from the msgbox, the name of the form that i chose,
is saved to strInput.
Then to open the form, i choise i will write:
DoCmd.OpenForm "strInput", , , , , ,
Can i do this?
If yes, could you give me some corrections to the code?
Thanks in advance