peterg290935 said:
I have tried to get the code to work, but this statement gives me a 3464
Run
Time Error
Set rstCodeTable = CurrentDb.OpenRecordset(strSql)
Is there an obvious syntax error?
Well, the question would be what does the sql look like. Put in the
following line of code right before the above
debug.print strSql
Now, after the above code runs, and fails, you can go to the immediate
window, and look at the sql you made
you can then cut/paste that sql into a new blank sql query. Just create a
new blank query, and then switch to sql view, and then paste in the sql from
your above test/debug.print.
You have got:
strSql = "select * from VolunteerActionCodes where ActionCode = '1'"
So, the debug.print code should produce:
select * from VolunteerActionCodes where ActionCode = '1'
So, try typing the above sql into a new blank query, and see what happens
(better yet, simply cut and paste the sql that appears in the
debug/immediate window for our debug.print).
Now, try and run your sql...does it run?
Perhaps ActionCode is a number type field, and not a string/text type field.
If that is the case, then you don't need quotes around the 1. This is case
where looking at your syntax will not help, and you will have to simply
check your sql here.
The rules for building sql are (I just kind of assumed that you coming from
a oracle background would have some sql skills here, and would realize how
correctly formed sql works here).
For numbers type fields in the table, you don't need quotes.
For strings/text type fields in the table, you need to surround your string
values with quotes.
Note that this rule applies to oracle, sql server, ms-access or virtually
any database engine that supports sql.
So, play around in the sql builder for a a while until you can get that sql
to work.
eg:
If actionCode is a stirng, then the sql would be
select * from VolunteerActionCodes where ActionCode = "1"
if ActionCode is a number type field, then the sql would be
select * from VolunteerActionCodes where ActionCode = 1
As I mentioned before, you *can* get away using single quotes around
strings, but you ARE supposed to use double quotes.
However, in the examples given, surrounding string values for the sql will
accept either type of quote.