Hello everyone. I need help with an insert statement that is erroring on me, and I cannot figure out why.
First, I have created two tables in the code:
dbs.Execute "CREATE TABLE explic(ssn TEXT, type TEXT, st TEXT, num TEXT, exp DATETIME);"
dbs.Execute "CREATE TABLE personal(ssn TEXT, fn TEXT, ln TEXT, st1 TEXT, st2 TEXT, city TEXT, state TEXT, zip TEXT);"
When I insert into the first table, explic, everything goes ok, :
strSql = "Insert into explic VALUES('" & rst.Fields("ssn" & "'" & _
", 'State Medical License', '" & rst.Fields("med_license_state" & "'" & _
", '" & rst.Fields("med_license_number" & "', '" & rst.Fields("license_exp" & "');"
DoCmd.RunSQL (strSql)
However, when I try inserting into the other table, I get a compilation error. The weird thing is I have typed the statement twice and I am getting errors in different places in the statements. The uncommented code that is giving me an error is:
strSql = "Insert into personal VALUES('" & rst.Fields("ssn" & _
"', '" & rst.Fields("first_name" & "'" & _
", '" & rst.Fields("last_name" & "', '" & rst.Fields("street1" & _
"', '" & rstFields("street2" & "'" & _
", '" & rst.Fields("city" & "', '" & rst.Fields("state" & _
"', '" & rst.Fields("zip" & "'); "
It is giving me a "Sub or Function not defined" error at rst.Fields("street1".
On the other (commented out) code that I have above it, typed pretty much the same, it is giving me the "sub or function not defined" error at rst.Fields("ssn" when I uncomment it.
Can anyone give me any insight as to what is causing this error? Is there something that I'm missing somewhere like a quote or anything like that? If you need any more info or code posted, let me know!
Thanks for any help that you can provide!!!
Janel
First, I have created two tables in the code:
dbs.Execute "CREATE TABLE explic(ssn TEXT, type TEXT, st TEXT, num TEXT, exp DATETIME);"
dbs.Execute "CREATE TABLE personal(ssn TEXT, fn TEXT, ln TEXT, st1 TEXT, st2 TEXT, city TEXT, state TEXT, zip TEXT);"
When I insert into the first table, explic, everything goes ok, :
strSql = "Insert into explic VALUES('" & rst.Fields("ssn" & "'" & _
", 'State Medical License', '" & rst.Fields("med_license_state" & "'" & _
", '" & rst.Fields("med_license_number" & "', '" & rst.Fields("license_exp" & "');"
DoCmd.RunSQL (strSql)
However, when I try inserting into the other table, I get a compilation error. The weird thing is I have typed the statement twice and I am getting errors in different places in the statements. The uncommented code that is giving me an error is:
strSql = "Insert into personal VALUES('" & rst.Fields("ssn" & _
"', '" & rst.Fields("first_name" & "'" & _
", '" & rst.Fields("last_name" & "', '" & rst.Fields("street1" & _
"', '" & rstFields("street2" & "'" & _
", '" & rst.Fields("city" & "', '" & rst.Fields("state" & _
"', '" & rst.Fields("zip" & "'); "
It is giving me a "Sub or Function not defined" error at rst.Fields("street1".
On the other (commented out) code that I have above it, typed pretty much the same, it is giving me the "sub or function not defined" error at rst.Fields("ssn" when I uncomment it.
Can anyone give me any insight as to what is causing this error? Is there something that I'm missing somewhere like a quote or anything like that? If you need any more info or code posted, let me know!
Thanks for any help that you can provide!!!
Janel