georgesOne
Technical User
Dear All:
I have a select query, which at one part needs variable vield names via a vba function.
The following query works:
Select A.ID, A.MS200810, A.MS200811, A.MS200812, IIf(A.MS200812 = A.MS200810,"","X") As GOMS
However the query:
Select A.ID, A.MS200810, A.MS200811, A.MS200812, IIf(bss_fGetDate1() = bss_fGetDate2(),"","X") As GOMS
does not work.
bss_fGetDate(1) and bss_fGetDate(2) are defined by VBA:
Function bss_fGetDate(1) As String
bss_fGetDate(1) = "A." & DFirst("MSLastDate", "atblDates")
End Function
Function bss_fGetDate(2) As String
bss_fGetDate(2) = "A." & DFirst("MS1Date", "atblDates")
End Function
and produce "A.MS200812" and "A.MS200810" respectively.
I understand that the query now compares the two strings "A.MS200812" and "A.MS200810" and correctly concludes the result is false (and "X" is what I see in all table rows). I believe the error comes from my function definition as String, but I do not know how to get the query understand that these are no strings but field names.
Thank you for any comments, georgesOne
I have a select query, which at one part needs variable vield names via a vba function.
The following query works:
Select A.ID, A.MS200810, A.MS200811, A.MS200812, IIf(A.MS200812 = A.MS200810,"","X") As GOMS
However the query:
Select A.ID, A.MS200810, A.MS200811, A.MS200812, IIf(bss_fGetDate1() = bss_fGetDate2(),"","X") As GOMS
does not work.
bss_fGetDate(1) and bss_fGetDate(2) are defined by VBA:
Function bss_fGetDate(1) As String
bss_fGetDate(1) = "A." & DFirst("MSLastDate", "atblDates")
End Function
Function bss_fGetDate(2) As String
bss_fGetDate(2) = "A." & DFirst("MS1Date", "atblDates")
End Function
and produce "A.MS200812" and "A.MS200810" respectively.
I understand that the query now compares the two strings "A.MS200812" and "A.MS200810" and correctly concludes the result is false (and "X" is what I see in all table rows). I believe the error comes from my function definition as String, but I do not know how to get the query understand that these are no strings but field names.
Thank you for any comments, georgesOne