I'm having a problem that I can't figure out. I've managed to pair it down to the bare essentials below.
In a module I have a public function and variable as below.
Public strObjName As String
Public Function GetObjName()
GetObjName = strObjName
End Function
In the On Click event of a button on a form I have
strObjName = Me.Name
And I've built this simple query
SELECT GetObjName() AS Expr1
FROM T_Obj_Name;
If I set a break point after strObjName has been set on the form and type "?GetObjName" in the immediate window
the name of the form is returned correctly. But if I try to run the query it fails with an "Unknown Jet Error". Clicking the help button displays "There was a type mismatch when creating a table validation rule or a CHECK constraint on a column. (Error 3072)"
I feel like I must be missing something obvious but the error message and the fact the function works in one instance and not the other makes no sense to me.
I know there are plenty of other ways of pulling the form's name but I'd like to understand what the issue is here.
In a module I have a public function and variable as below.
Public strObjName As String
Public Function GetObjName()
GetObjName = strObjName
End Function
In the On Click event of a button on a form I have
strObjName = Me.Name
And I've built this simple query
SELECT GetObjName() AS Expr1
FROM T_Obj_Name;
If I set a break point after strObjName has been set on the form and type "?GetObjName" in the immediate window
the name of the form is returned correctly. But if I try to run the query it fails with an "Unknown Jet Error". Clicking the help button displays "There was a type mismatch when creating a table validation rule or a CHECK constraint on a column. (Error 3072)"
I feel like I must be missing something obvious but the error message and the fact the function works in one instance and not the other makes no sense to me.
I know there are plenty of other ways of pulling the form's name but I'd like to understand what the issue is here.