VBA DELETE command does not work

Asked

Viewed 702 times

1

I have a project that adds and eliminates dates, to add I have the following code:

   Set dbs = CurrentDb
   dbs.Execute " INSERT INTO TMP " _
   & "(diaMes) VALUES( " _
    & "'" & tmp7 & "') "

where tmp7 is the date in dd-mm-yyyy and works perfectly

and to withdraw use of the following code:

    Set dbs = CurrentDb
   dbs.Execute " DELETE * FROM TMP " _
   & "WHERE diaMes=#" & tmp7 & "#;"

The problem is that eliminating only eliminates if the day is over 12, ie I understand that if the day is less than or equal to 12 is interpreting as mm-dd-yyyy

tmp7 is a string with string concatenation.

How can I force SQL to pass as dd-mm-yyyy ?

The field in the table is like this: tabela

  • Thanks friend, I tbm was with this problem. Thanks for the help!!

1 answer

2


I figured out how to do,

    Set dbs = CurrentDb
    dbs.Execute "DELETE * FROM TMP WHERE diaMes = " & _
    Format(tmp7, "\#mm\/dd\/yyyy\#")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.