Delete record howto?

M

Mike J

I have a table that has an ID field and a Date field.
There would be many records with the same ID in this table
but all the dates for that ID are different. So, I wanna
search for a record with an ID and a specific date and
then delete it. I'm having trouble doing this; can
someone show me how? Thanks.
 
R

Rick Brandt

Mike J said:
I have a table that has an ID field and a Date field.
There would be many records with the same ID in this table
but all the dates for that ID are different. So, I wanna
search for a record with an ID and a specific date and
then delete it. I'm having trouble doing this; can
someone show me how? Thanks.

If the date has no time component (actually a time of midnight) then it
would be something like...

DELETE * FROM YourTableName
WHERE ID = 123
AND DateField = #1/1/2004#
 
M

Mike J

-----Original Message-----


If the date has no time component (actually a time of midnight) then it
would be something like...

DELETE * FROM YourTableName
WHERE ID = 123
AND DateField = #1/1/2004#


.
Thanks for the fast comeback. I can then use variables
instead of constants?
 
A

Allen Browne

Sure. This example picks up the values form text boxes on your form:

strSql = "DELETE FROM YourTableName WHERE (([ID] = " & Me.txtWhatID & ") AND
([DateField] = #" & Format(Me.txtWhatDate, "mm\/dd\/yyyy") & "#));"

dbEngine(0)(0).Execute strSql, dbFailOnError
 
M

Mike J

-----Original Message-----
I have a table that has an ID field and a Date field.
There would be many records with the same ID in this table
but all the dates for that ID are different. So, I wanna
search for a record with an ID and a specific date and
then delete it. I'm having trouble doing this; can
someone show me how? Thanks.
.
I tried this stmnt(s) in the code:
strDelRnd = "Delete * From rstRound Where (([id] = " &_
MainID & ") AND ([Date Played] = Rnd_Date));"
DBEngine(0)(0).Execute strDelRnd, dbFailOnError

and got a syntax error. Rnd_date is formatted with the
#'s around it in a previous stmnt above. I thought this
would work per previous update. What am I doing wrong or
not seeing? Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top