So I have a subform VBA function that looks like this:
Function GetVariable() As Double
' <control> = DLookup("<table var>","<table>", "<other table var> = <control>"
[someFunction] = DLookup("[Var]", "[tblExample]", "[tblExampleVar] = [subFormControl]")
' (return) = ( <control> - <otherControl>) / 12345.12
GetVariable = ([finalPosition] - [someFunction]) / 12345.12
End Function
And when I open the parent form (the form that contains this subform), I get the error, "Run-time error '2447' There is an invalid use of the . (dot) or ! operator or invalid parentheses."
What I gather from this is that Access is interpreting 12345.12 as an object and I do not understand why. When I run this subform on its own it works, but when it is a subform it does not. Has anyone dealt with this before?
Extra information: I have two subforms in this parent form that use the same calculation, both repeated in their form-specific VBA, and I do not think that they would conflict with one another because they do not share scope. So my conclusion remains that Access is trying to use 12345.12 as (object).member.
Thanks for reading.
12345.12
value - it's not even seeing it. Access only sees/evaluates the bracketed expressions. IIRC a function that is meant to be invoked from an Access document (form, report, ..query) needs to return aVariant
- but don't quote me on that, I don't use Access. Does it still blow up if you change the function's return type toVariant
? -- edit: scratch that, I missed the part where it works when used on its own. – Mathieu Guindon[someFunction]
– Mathieu Guindontable var
andother table var
? – June7