hello, I have been driving myself crazy with the syntax below. It looks simple but I have not been able to get it to work. I have a form with 2 unbound text boxes FirstRecordL and LastRecordL. I want the user to input the range for deleting records in those 2 boxes. then there is a command btn in that same form with the onclick event that will execute the SQL reading the values from those 2 text boxes.
could you please help me figure out how to make it work. or any study guide for the " and ' when doing those things? I know the issue is in there because when I use
DoCmd.RunSQL ("DELETE FROM CTRTable ") it deletes everything without issues. so, I know I have an error with the where condition.
it also works when I manually hardcode the number. DoCmd.RunSQL ("DELETE FROM CTRTable where [ctr #] = 123")
regards,
prado
Kevin Robertson
@Reply 3 years ago
Is [ctr #] a number field? If so you don't need the quotes around the field names. You only need the quotes for text fields.
Scott Axton
@Reply 3 years ago
Alberto,
I don't know if this is a db that you have in production or it is one that is still in development.
I highly recommend that you change your field name from ctr # to something different.
1. You should not have spaces in your field names.
2. the # symbol is a special reserved character used in signifying dates.
Even though you have square brackets surrounding the field - [ctr #] - you are just asking for problems down the line by not changing it sooner than later.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Visitor Forum.