T
tobesurveyor via AccessMonster.com
Good Morning,
I am a novice when it comes to VBA. I have made a couple of applications
using the same methods of using VBA. I am now going back and trying to make
things quicker as well as trying to clean up my code.
Is there a way to pass variables between functions in code?
Right now I have an OnClick event to call Launch01 thru Launch14 based upon
the image they click on the form. When they click on of these, the area
clicked highlights. I want that highlight color to change based upon an
option in a table called tblChoiceMenuColor. Unfortunately I do not know how
to transfer the variable solved for in the Private Sub FindColor for the
variable ColorCode to each Me.bxLaunch##.BackColor in each OnClick event.
Please see below.
Private Sub FindColor()
ColorNameID = DLookup("[ChoiceMenuColorID]", "tblLocalSettings",
"[LocalSettingsID] = 1")
ColorImgName = DLookup("[FileName]", "tblChoiceMenuColor", "
[ChoiceMenuColorID] = " &
ColorNameID)
ColorCode = DLookup("[ColorCode]","tblChoiceMenuColor","
[ChoiceMenuColorID] = "& ColorNameID)
End Sub
Private Sub Launch01()
FindColor
Me.bxLaunch01.BackStyle = 1
Me.bxLaunch01.BackColor = 16250335 <<<<I want to pass the variable
ColorCode Here
End Sub
Private Sub Launch02()
FindColor
Me.bxLaunch02.BackStyle = 1
Me.bxLaunch01.BackColor = 10485760 <<<<I want to pass the variable
ColorCode Here
End Sub
Any help would be greatly appreciated.
Thanks,
CF
I am a novice when it comes to VBA. I have made a couple of applications
using the same methods of using VBA. I am now going back and trying to make
things quicker as well as trying to clean up my code.
Is there a way to pass variables between functions in code?
Right now I have an OnClick event to call Launch01 thru Launch14 based upon
the image they click on the form. When they click on of these, the area
clicked highlights. I want that highlight color to change based upon an
option in a table called tblChoiceMenuColor. Unfortunately I do not know how
to transfer the variable solved for in the Private Sub FindColor for the
variable ColorCode to each Me.bxLaunch##.BackColor in each OnClick event.
Please see below.
Private Sub FindColor()
ColorNameID = DLookup("[ChoiceMenuColorID]", "tblLocalSettings",
"[LocalSettingsID] = 1")
ColorImgName = DLookup("[FileName]", "tblChoiceMenuColor", "
[ChoiceMenuColorID] = " &
ColorNameID)
ColorCode = DLookup("[ColorCode]","tblChoiceMenuColor","
[ChoiceMenuColorID] = "& ColorNameID)
End Sub
Private Sub Launch01()
FindColor
Me.bxLaunch01.BackStyle = 1
Me.bxLaunch01.BackColor = 16250335 <<<<I want to pass the variable
ColorCode Here
End Sub
Private Sub Launch02()
FindColor
Me.bxLaunch02.BackStyle = 1
Me.bxLaunch01.BackColor = 10485760 <<<<I want to pass the variable
ColorCode Here
End Sub
Any help would be greatly appreciated.
Thanks,
CF