|
Question : VBA - Calling a function from outside a Private Sub
|
|
Hi guys,
I have this code:
Dim Category As String Category = "General"
Private Sub lstVehicles_Click() If Category = "General" Then Me.mysubForm.Form.RecordSource = "SELECT * FROM tblVehicle WHERE UID=" & lstVehicles.Value End If End Sub
and I get this error:
The expression On Click you entered as the event property setting produced the following error: Invalid outside procedure.
How do I get around this? Would I need to move the code into a Function and call the function my Sub?
Cheers guys!
|
|
Answer : VBA - Calling a function from outside a Private Sub
|
|
>Category = "General" that line needs to be inside a procedure...
like :
Dim Category As String
Private Sub lstVehicles_Click() If Category = empty then Category = "General" If Category = "General" Then Me.mysubForm.Form.RecordSource = "SELECT * FROM tblVehicle WHERE UID=" & lstVehicles.Value End If End Sub
|
|
|