Microsoft Jet Engine Cannot Find Input Table

Rocinante

Registered User.
Local time
Today, 09:05
Joined
Feb 28, 2005
Messages
12
I have a peice of code that I want to use many times. It is a DCount function and I want to use a defined string to hold the table name in the DCount function. ie I will be performing the same DCount function on many tables.

This code returns the error "The Microsoft Jet database engine cannot find the input table 'tbl_Compliments_Log' " Now the table exists and is spelt correctly. If I cut and past the table name into the DCount function in stead of " & strMyTable & " it works ok.

Dim strMyTable As String
strMyTable = "tbl_Compliments_Log"

CompsYTD = DCount("*", " " & strMyTable & " ", "Year(Date_Raised) like " & myYear & "")

Thanks & Regard

Stephen
 
Try without the extra quotes

CompsYTD = DCount("*", strMyTable , "Year(Date_Raised) = " & myYear)

or with [brackets]

CompsYTD = DCount("*", "[" & strMyTable & "]", "Year(Date_Raised) = " & myYear)

The Like operator will probably not work with numerics, try replacing with =
 

Users who are viewing this thread

Back
Top Bottom