By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,479 Members | 2,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,479 IT Pros & Developers. It's quick & easy.

Need Help in delete command event

P: 4
I am really new to visual basic programming language. I want to design a form with a list box and delete button. when i select a particular month and press delete it will delete with the query. the code dont work. hope u guys can help pls. thx in advance


Private Sub Command4_Click()

ListBox ListBox1

Month1 = ListBox1.Value

Dim SQL As String

SQL = "DELETE FROM Table2 where Datetime = Month1 "


MsgBox "Deleted !"



End Sub
Sep 8 '07 #1
Share this Question
Share on Google+
4 Replies


FishVal
Expert 2.5K+
P: 2,653
I am really new to visual basic programming language. I want to design a form with a list box and delete button. when i select a particular month and press delete it will delete with the query. the code dont work. hope u guys can help pls. thx in advance


Private Sub Command4_Click()

ListBox ListBox1

Month1 = ListBox1.Value

Dim SQL As String

SQL = "DELETE FROM Table2 where Datetime = Month1 "


MsgBox "Deleted !"



End Sub
Hi, there.

Take a look at "Month" VBA function.
Sep 8 '07 #2

P: 4
hihi thx....
But wher do i look at "Month" VBA function.?
Sep 8 '07 #3

P: 4
Hey i saw the month function , but the current problem is i do not know how do the delete query. Is the any required connection to the database from the vba codes. when i view the form and click the button, it does not execute the query.
Sep 8 '07 #4

FishVal
Expert 2.5K+
P: 2,653
Hey i saw the month function , but the current problem is i do not know how do the delete query. Is the any required connection to the database from the vba codes. when i view the form and click the button, it does not execute the query.
:)

And now take a look at DoCmd.RunSQL.

Regards,
Fish
Sep 9 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.