Docmd.runSQL problem

  • Thread starter Thread starter Joe Williams
  • Start date Start date
J

Joe Williams

hi, I am trying to execute code to delete a record that has a concatenated
primary key of two fields. I am getting a 3061 error: "two few parameters"
whenthe docmd.runSQL command is executed. I am sure it is something to do
with how I am building the SQL statement. Here is my code to build the SQL:

strSQL = "Delete * From Levels Where [PolicyLevel]=""" & strLevels & """ and
[PolicyName]=""" & strName & """"

What I am doing wrong in order to delete a record with a conatenated primary
key?

THanks

Joe
 
My first inclination is that your query's SQL is using field names that are
not in the Levels table.
 
hi, I am trying to execute code to delete a record that has a concatenated
primary key of two fields. I am getting a 3061 error: "two few parameters"
whenthe docmd.runSQL command is executed. I am sure it is something to do
with how I am building the SQL statement. Here is my code to build the SQL:

strSQL = "Delete * From Levels Where [PolicyLevel]=""" & strLevels & """ and
[PolicyName]=""" & strName & """"

you double quotes are not right
Suggestion: use single quotes for string values like
strSQL = "DELETE * FROM Levels WHERE [PolicyLevel]='" & strLevels _
& "' AND [PolicyName]='" & strName & "'"

If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW
 
Andi Mayer said:
hi, I am trying to execute code to delete a record that has a concatenated
primary key of two fields. I am getting a 3061 error: "two few parameters"
whenthe docmd.runSQL command is executed. I am sure it is something to do
with how I am building the SQL statement. Here is my code to build the SQL:

strSQL = "Delete * From Levels Where [PolicyLevel]=""" & strLevels & """ and
[PolicyName]=""" & strName & """"

you double quotes are not right
Suggestion: use single quotes for string values like
strSQL = "DELETE * FROM Levels WHERE [PolicyLevel]='" & strLevels _
& "' AND [PolicyName]='" & strName & "'"

Assuming PolicyLevel and PolicyName are both text fields, I don't see
anything wrong with the double quotes Joe has.
 
Assuming PolicyLevel and PolicyName are both text fields, I don't see
anything wrong with the double quotes Joe has.

Douglas you are right, I think i need glases, or a bigger screen
If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW
 
Back
Top