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!

obtainig the date through a form 1

Status
Not open for further replies.

primerov

Technical User
Aug 16, 2002
160
0
0
BG

I have a code that sets all dates before 01.01.2003, expressed with <#1/1/2002 like that:

" WHERE (((orders.orderdate)<#1/1/2002#));"


Is it possible to enable the user to choose the dates in a form ? For example, build a table
called Table1 ,and a field called Fiel1 then a form called Form1 and then obtain the date in the expression
from the date in the form.Somehing like that:
< Forms![Form1]![Field1]

In this way the user will be able to set the dates himself without writing the code <#1/1/2002#

Is it possible ?
 
Provided the form is open when the query is launched, simply put this in the criteria box of orders.orderdate;
<"#" & Format(Forms!Form1!Field1, "m/d/yyy") & "#"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you so much for your advice
 


Could you help me find out the error ? I get the following error :

Run time error 3075
Missing ), ] or Item in query expression ((([orders].[orderdate]])> '#' & Format(Forms!frmCutDates!CutDate, 'm/d/yyy') & '#'"



Here is my whole coding



Private Const CnstCutDate As String = " WHERE ((([orders].[orderdate])>'#' & Format(Forms!frmCutDates!CutDate, 'm/d/yyy') & '#'"
Private Sub Command4_Click()
CutOff
End Sub
Private Function CutOff()
Dim SqlRemoveFromOrders As String
SqlRemoveFromOrders = "DELETE DISTINCTROW orderdate FROM orders "
CurrentDb.Execute SqlRemoveFromOrders & CnstCutDate
End Function



 
Remove this line (you can't use function in constant declaration) :
Private Const CnstCutDate As String = " WHERE ((([orders].[orderdate])>'#' & Format(Forms!frmCutDates
And add this in the CutOff body:
Dim CnstCutDate As String
CnstCutDate = " WHERE orderdate>#" & Format(Forms!frmCutDates!CutDate, "m/d/yyy") & "#;"

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