Clear values in a table column

kenicho2

New Member
Joined
Feb 2, 2004
Messages
15
All I want is a button that will clear all data in a specific column of a table. I created my form, added a button, and entered the following SQL statment...

Sub Command3_Click()

Update RecipeList
Set DayID = Null

End Sub

When I run it, I get "Compile error: Sub or Function not defined". I can run other sql statements, such as to display a message box. It just does not seem to recognize the "Update" statement. What am I doing wrong? Thanks for helping this amateur!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Your SQL statement is correct but to run it you need a slightly different syntax:

Code:
Sub Foo()

DoCmd.RunSQL ("Update RecipeList Set DayID = Null;")

End Sub

If you want the command to execute "silently" then:
Code:
Sub Foo()

DoCmd.SetWarnings False
DoCmd.RunSQL ("Update RecipeList Set DayID = Null;")
DoCmd.SetWarnings True
 
End Sub

ξ
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,547
Members
452,925
Latest member
duyvmex

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top