DoCmd.RunSQL ("DELETE

GregSmith

Registered User.
Local time
Today, 15:11
Joined
Feb 22, 2002
Messages
126
The fields I am looking to delete in the table called table_rules
Are MAIN, SUB, RULE, SOURCE, DESTINATION.

Here is the command I am using:
DoCmd.RunSQL ("DELETE table_rules.* FROM table_rules WHERE (((table_rules.RULE)=" & Me.Rule & "));")

I am getting a data mismatch error.
Does someone know how to delete to the whole line from table_rules?

Thanks, Greg
 
I'm guessing that Me.Rules is a text field. If you're trying to delete ALL fields form the table with matching RULE field, try this:
DoCmd.RunSQL ("DELETE * FROM table_rules WHERE table_rules.RULE='" & Me.Rule & "';")

You don't need all those extra parentheses.

If you're getting a confirmation message and would like to get rid of it, use the Currentdb.Execute or CurrentProject.Connection.Execute syntax instead.
 
That works great except it deletes all rules of the same number.
I only need it to delete the online.

I am trying to take your example and add this:

DoCmd.RunSQL ("DELETE * FROM table_rules WHERE table_rules.RULE='" & Me.Rule & ";" & "'" & table_rules.MAIN='" & IconParent & "'")

I get a syntax error now.
 
This did it:

DoCmd.RunSQL ("DELETE * FROM table_rules WHERE " & _
" table_rules.RULE = '" & Me.Rule & ";" & "' AND " & _
" table_rules.MAIN = '" & IconParent & "' AND " & _
" table_rules.SUB = '" & IconChild & "' ")

Now I delete the correct line without touching the rest of the table.

Thanks for the lead dcx693!! You got me in the right direction.
 

Users who are viewing this thread

Back
Top Bottom