By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

Running select statement into a recordset from a form

P: 3
I am getting error 3078 Microsoft jet datbase engine cannot find the input table or query .... make sure it exists & that it's spelled correctly

I am using list & text boxes on a form to capture the table/field names and then use for my code as follows:

strSQL = """SELECT Sum([" & Tbl_To_Decile & "].[" & What_Col & "]) AS [Total_TRX] FROM [" & Tbl_To_Decile & "]"")"

Set Ttrxr = DBEngine(0)(0).OpenRecordset(strSQL)

And when I run it I get the error

When I debug.print strSQL I get the following:
"SELECT Sum([Prescriber Ranking data (Flector)].[YTD Aug TRX]) AS [Total_TRX] FROM [Prescriber Ranking data (Flector)]")

When I replace the set line with the following spelled out version it works fine:

Set Ttrxr = DBEngine(0)(0).OpenRecordset("SELECT Sum([Prescriber Ranking data (Flector)].[YTD Aug TRX]) AS [Total_TRX] FROM [Prescriber Ranking data (Flector)]")

This is the exact same line my code is generating, so why won't my code work?
Oct 28 '08 #1
Share this Question
Share on Google+
4 Replies


P: 93
Hi

My suggestion below

strSQL = """SELECT Sum([" & Tbl_To_Decile & "].[" & What_Col & "]) AS [Total_TRX] FROM [" & Tbl_To_Decile & "]"")"

The last bit above looks suspicious

Again the last bit looks suspicious
"SELECT Sum([Prescriber Ranking data (Flector)].[YTD Aug TRX]) AS [Total_TRX] FROM [Prescriber Ranking data (Flector)]")

Hope it helps
Emil
Oct 28 '08 #2

P: 3
Not sure what your suggestion is...
Oct 29 '08 #3

P: 93
sorry I wasn't very clear

instead of:
strSQL = """SELECT Sum([" & Tbl_To_Decile & "].[" & What_Col & "]) AS [Total_TRX] FROM [" & Tbl_To_Decile & "]"")"

try
strSQL = "SELECT Sum([" & Tbl_To_Decile & "].[" & What_Col & "]) AS [Total_TRX] FROM [" & Tbl_To_Decile & "])"

Regards
Emil
Oct 29 '08 #4

P: 3
Emil,

It worked perfectly - Thanks!
Oct 29 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.