CurrentDb.Execute

CurrentDb.Execute "DELETE FROM tblAppointments WHERE tblAppointments.MedewerkerID = " & Me.txtMedewerker.Column(0) & " And ApptEnd <= #" & Me.txtEndDate & "#" _
    & " And ApptStart >= #" & Me.txtStartDate & "#"

dosn't work...can you help me?
ertjanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

als315Commented:
Can you assign SQL to variable and show result here:
Dim SQL as string
SQL = "DELETE FROM tblAppointments WHERE tblAppointments.MedewerkerID = " & Me.txtMedewerker.Column(0) & " And ApptEnd <= #" & Me.txtEndDate & "#" _
    & " And ApptStart >= #" & Me.txtStartDate & "#"
debug.print SQL

Open in new window

0
als315Commented:
Try also:
DELETE * FROM
0
Dale FyeCommented:
I don't see anything that jumps out at me other than the reference to a column(0) as a property of a text control (txtMedewerker).  My guess is that is actually either a combo box or a listbox, but if so, why would you prefix the control name with "txt"?

I would rewrite it as below.  This allows you to print out the SQL string to view what it looks like, and adding the dbFailOnError to the Execute method will raise an error if one is encountered with the code.

Dim strSQL as string
strSQL = "DELETE FROM tblAppointments " _
            & "WHERE tblAppointments.MedewerkerID = " & Me.txtMedewerker.Column(0) _
            & " And ApptEnd <= #" & Me.txtEndDate & "# AND" _
            & " And ApptStart >= #" & Me.txtStartDate & "#"

debug.print strsql
CurrentDb.Execute  strsql, dbfailonerror
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ertjanAuthor Commented:
Work perfect thanks :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.