Using a variable as a field name, I'm unable to get this query statement to work. I've manually entered the statement into the query design, and I receive the same error of "data type mismatch in criteria expression." Here's the vital info:
This is the SQL statement that was created within the query design and it works:
SELECT tblMasterTitleTopics.ReferenceID, tblMasterTitleTopics.Africa FROM tblMasterTitleTopics WHERE (((tblMasterTitleTopics.ReferenceID) = "9999"))
This statement was created in VBA code, and I receive the error message:
stritem = "9999"
str0 = "Africa"
strquery = "SELECT [tblMasterTitleTopics].[ReferenceID], [tblMasterTitleTopics].["
strquery = strquery & str0 & "] FROM tblMasterTitleTopics WHERE ((([tblMasterTitleTopics].[ReferenceID]) = "
strquery = strquery & Chr(34) & stritem & Chr(34) & "))"
I think the problem is because I'm using a variable to create the field name, but I don't know how to fix it. Thanks in Advance!!
This is the SQL statement that was created within the query design and it works:
SELECT tblMasterTitleTopics.ReferenceID, tblMasterTitleTopics.Africa FROM tblMasterTitleTopics WHERE (((tblMasterTitleTopics.ReferenceID) = "9999"))
This statement was created in VBA code, and I receive the error message:
stritem = "9999"
str0 = "Africa"
strquery = "SELECT [tblMasterTitleTopics].[ReferenceID], [tblMasterTitleTopics].["
strquery = strquery & str0 & "] FROM tblMasterTitleTopics WHERE ((([tblMasterTitleTopics].[ReferenceID]) = "
strquery = strquery & Chr(34) & stritem & Chr(34) & "))"
I think the problem is because I'm using a variable to create the field name, but I don't know how to fix it. Thanks in Advance!!