Results 1 to 3 of 3
Thread: dbs.execute "delete...
2001-02-27, 02:23 #1DavidMadgeGuest
I'm trying to delete a specific record from a table that isn't bound to the form(s) I currently have open. I'm using:
Dim dbs As Database
Dim strSQL As String
Set dbs = CurrentDb
strSQL = "DELETE * FROM tblPropertiesCertified WHERE" _ & " CertPropCode =Parent![fsubPropertyName].Form!" _
dbs.Execute strSQL, dbFailOnError
Set dbs = Nothing
Even if I replace the =Parent... section with a specific number I get an error message about 'Too few parameters'.
I'm using Access97. CertPropCode in the FROM table is an autonumber field.
What am I missing ?
2001-02-27, 03:30 #2
- Join Date
- Feb 2001
- Melbourne, Victoria, Australia
- Thanked 0 Times in 0 Posts
Try putting in a bit of debugging; such as debug.print strSQL or msgbox strSQL.
What is happening is that your reference to the control is being used as text, and it isn't referring to the control at all. I am not certain but the parameters error may arise from not explicitly stating the table in the WHERE clause.
Give this a go:<pre> strSQL = "DELETE * FROM tblPropertiesCertified WHERE " _
& "tblPropertiesCertified.CertPropCode = " _
2001-02-27, 03:52 #3DavidMadgeGuest
Re: the table name, because I only refer to the one table, I don't need to repeat its name in the WHERE clause. My problem was indeed putting the control reference inside the "" making it text and therefore unevaluatable (if there is such a word).