T
th34
I have 2 sub forms SubFormA and SubFormB. I am looking to
change the name of my subform depending which one is
visible. I have the following code but it does not seem
to work for me. Any suggestions would be greatly
appreciated.
Code below sits in the module:
Public FormName as String-----the variable declare in the
module
Public Sub Test1(FormName As String)
Forms![MainForm]!FormName.Form![First_Name].BackStyle
= "1"
Forms![MainForm]!FormName.Form![First_Name].BackColor
= "255"
End Sub
Public Sub Test2(FormName As String)
Forms![MainForm]!FormName.Form![First_Name].BackStyle
= "1"
Forms![MainForm]!FormName.Form![First_Name].BackColor
= "65535"
End Sub
-calling the code in the sub form
Private Sub Form_Current()
If Len(Me!ID) = 0 Then
Test1 Me.Name
Else
Test2 Me.Name
End If
End Sub
If I use a msgbox function, it prints out the subform name
for me but I just don't know how to pass into the
reference below. I've tried the following and it does not
work. Am I passing the variable wrong???
1) "Forms![MainForm]!" & FormName & ".Form!
[First_Name].BackColor = 255"
2) Forms![MainForm]! [FormName].Form!
[First_Name].BackColor = "255"
3) I also tried break the string up into 2 different
variables and concetenating them all together
change the name of my subform depending which one is
visible. I have the following code but it does not seem
to work for me. Any suggestions would be greatly
appreciated.
Code below sits in the module:
Public FormName as String-----the variable declare in the
module
Public Sub Test1(FormName As String)
Forms![MainForm]!FormName.Form![First_Name].BackStyle
= "1"
Forms![MainForm]!FormName.Form![First_Name].BackColor
= "255"
End Sub
Public Sub Test2(FormName As String)
Forms![MainForm]!FormName.Form![First_Name].BackStyle
= "1"
Forms![MainForm]!FormName.Form![First_Name].BackColor
= "65535"
End Sub
-calling the code in the sub form
Private Sub Form_Current()
If Len(Me!ID) = 0 Then
Test1 Me.Name
Else
Test2 Me.Name
End If
End Sub
If I use a msgbox function, it prints out the subform name
for me but I just don't know how to pass into the
reference below. I've tried the following and it does not
work. Am I passing the variable wrong???
1) "Forms![MainForm]!" & FormName & ".Form!
[First_Name].BackColor = 255"
2) Forms![MainForm]! [FormName].Form!
[First_Name].BackColor = "255"
3) I also tried break the string up into 2 different
variables and concetenating them all together