Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cutting off dates 1

Status
Not open for further replies.

primerov

Technical User
Aug 16, 2002
160
0
0
BG
I have a function that cuts off dates that works well. I want however to imrpove the function allowing the user to add on dates through a table and a form.The new form is called FrmUpdates anf the control CutDate.

Instead of using the constant CutDate i want to use the control CutDate like that :

Dim CutDate As String

Set CutDate = > FrmCutdates![CutDate]

I have 2 questions.First, somehow Acces does not accept my line
Set CutDate > FrmCutdates![CutDate]
Second, the date in the control shows the reverse date, for example
instead of 06.30.2003 it shows 30.06.2003

How can i correct them ?

Below is my working function




Public Const CutDate As String = " WHERE ((([orders].[orderdate])>#06/30/2003#));"
Public Function CutOff()
Dim SqlRemoveFromOrders As String
SqlRemoveFromOrders = "DELETE DISTINCTROW orderdate FROM orders "
CurrentDb.Execute SqlRemoveFromOrders & CutDate
End Function






 
'Set CutDate = > FrmCutdates![CutDate]'

I haven't looked atthe whole question but this is incorrectin two ways.

First, you don't use Set when assigning a value to a normal variable (only for an object variable).
Second, the = > is meaningless. I don't understand what you are trying to express here.
 
Replace this;
CurrentDb.Execute SqlRemoveFromOrders & CutDate
By this:
CurrentDb.Execute "DELETE * FROM orders WHERE orderdate>#" & Format(Forms!FrmCutdates!CutDate, "m/d/yyyy") & "#;"
Obviously, the form FrmCutdates must be open when this function is called.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top