karmacable
Registered User.
- Local time
- Today, 09:53
- Joined
- Sep 13, 2011
- Messages
- 32
I have some long code which I'm attempting to simplify through variables, but I'm not achieving success. Here's the original code;
It works great. Now, when I try to setup variable for the long Me.xxx names and such like this;
Nothing happens! I even tried setting all the variable as 'Variant', but again the code doesn't run. Any suggestions?
PHP:
Dim Cameras As String
If Me.cmb1stCamACam & Me.cmb1stCamBCam <> 0 Then
If Me.cmb1stCamACam = Me.cmb1stCamBCam Then
Cameras = "2 x " & Me.cmb1stCamACam.Column(1)
Me.lbl1stCameras.Caption = Cameras
Else
Cameras = "1 x " & Me.cmb1stCamACam.Column(1) & vbNewLine & "1 x " & Me.cmb1stCamBCam.Column(1)
Me.lbl1stCameras.Caption = Cameras
End If
Else
lbl1stCamera.Caption = ""
End If
It works great. Now, when I try to setup variable for the long Me.xxx names and such like this;
PHP:
Dim Cameras As String
Dim CamA As Integer
Dim CamB As Integer
Dim CamAName As String
Dim CamBName As String
Dim Caption As String
CamA = Me.cmb1stCamACam
CamB = Me.cmb1stCamBCam
CamAName = Me.cmb1stCamACam.Column(1)
CamBName = Me.cmb1stCamBCam.Column(1)
Caption = Me.lbl1stCameras.Caption
If CamA & CamB <> 0 Then
If CamA = CamB Then
Cameras = "2 x " & CamAName
Caption = Cameras
Else
Cameras = "1 x " & CamAName & vbNewLine & "1 x " & CamBName
Caption = Cameras
End If
Else
Caption = ""
End If
Nothing happens! I even tried setting all the variable as 'Variant', but again the code doesn't run. Any suggestions?
Last edited: