Problem with query accessing VBA function

ImoBase

New member
Local time
Today, 13:53
Joined
Aug 20, 2012
Messages
9
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
 
Try to set the datatype your funtion returns by:
Code:
Public Function GetComboAttending() [B]as String[/B]
 
Thanks for the reply, appreciated. Didn't work, I'm afraid. Any other thoughts?
 
Solved...! It would appear that the variable that is passed into my function has a preceding space. Put into a query, designed for an exact match without a leading space, the query of course failed. Thanks again.
 

Users who are viewing this thread

Back
Top Bottom