Results 1 to 3 of 3
  1. #1

    dbs.execute "delete...


    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!" _
    & "[CertPropCode];"
    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 ?

  2. #2
    Star Lounger
    Join Date
    Feb 2001
    Melbourne, Victoria, Australia
    Thanked 0 Times in 0 Posts

    Re: dbs.execute

    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 = " _
    & Parent![fsubPropertyName].Form![CertPropCode]
    & ";"
    MsgBox strSQL
    dbs.Execute strSQL</pre>

  3. #3

    Re: dbs.execute

    Thanks Marty

    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).


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts