date field format for a query field

  • Thread starter Thread starter roger
  • Start date Start date
R

roger

Hello friends:
How would I enter a format of eg. 03/02/2003 for a prompt
which come up for a query..at run time. This is to see to
it that the user enters the format above only for entering
the dates and nothing else.
 
roger said:
Hello friends:
How would I enter a format of eg. 03/02/2003 for a prompt
which come up for a query..at run time. This is to see to
it that the user enters the format above only for entering
the dates and nothing else.

I don't know how to modify the query prompt, but if you look at this example
, it might help.


QUERY:

SELECT [Invoice], [Invoice_Date]
FROM tblInvoice
WHERE [Invoice_Date]>GetUserDate();



Put the following function in your code:

Public Function GetUserDate() As Date
Dim TheUserDateString As String
TheUserDateString = InputBox("Enter Invoice Date", "INVOICE DATE ENTRY",
"mm/dd/yyyy")
While Not IsDate(TheUserDateString)
TheUserDateString = InputBox("You have entered an incorrect date format.
Please enter date as mm/dd/yyyy.", "INVOICE DATE ENTRY", "mm/dd/yyyy")
Wend

GetUserDate = CDate(TheUserDateString)
End Function
 
The parameter box does not have the power you need.

Consider using a small unbound form for the purpose. You can refer to it in
the query, e.g. by typing something like this into the Criteria row under
your date field:
=[Forms]![Myform]![MyDate]
 
Back
Top