I have written some MS ACCESS 2003 VBA that allows a variable to be passed to a query, using a form to harvest criteria for the query.
Unfortunately, the variable does not seen to be passed on to the query, although the query function call is triggering the VBA - it just dosn't seem to be returning the value into the query. I have tested the rest of the code and the value I am trying to get into the query criteria is working up to the point of the query calling the function, the function code working, and then the criteria doesn't work in the query.
I have another function in the same query, set up the same way, and that one works fine for an integer value that I am using to return a unique event ID.
Thoughts appreciated.
-------------------
Form code
-------------------
' test variable when a button is pressed
strAttending = "Confirmed"
SetComboAttending strAttending
' code here to open query
-------------------
Query call
-------------------
' Function in the string field of interest
GetComboAttending()
-------------------
Module code
-------------------
Option Compare Database
Option Explicit
'********** GLOBAL VARIABLES *********
Public strAttendingStatus As String
'*************************************
Public Sub SetComboAttending(Value As String)
strAttendingStatus = Value
End Sub
Public Function GetComboAttending()
GetComboAttending = strAttendingStatus
End Function
Unfortunately, the variable does not seen to be passed on to the query, although the query function call is triggering the VBA - it just dosn't seem to be returning the value into the query. I have tested the rest of the code and the value I am trying to get into the query criteria is working up to the point of the query calling the function, the function code working, and then the criteria doesn't work in the query.
I have another function in the same query, set up the same way, and that one works fine for an integer value that I am using to return a unique event ID.
Thoughts appreciated.
-------------------
Form code
-------------------
' test variable when a button is pressed
strAttending = "Confirmed"
SetComboAttending strAttending
' code here to open query
-------------------
Query call
-------------------
' Function in the string field of interest
GetComboAttending()
-------------------
Module code
-------------------
Option Compare Database
Option Explicit
'********** GLOBAL VARIABLES *********
Public strAttendingStatus As String
'*************************************
Public Sub SetComboAttending(Value As String)
strAttendingStatus = Value
End Sub
Public Function GetComboAttending()
GetComboAttending = strAttendingStatus
End Function