Wayne:
I was about to take you to task for not suggesting:
=Format(Now(),"dd/mm/yyyy hh:nn AM/PM)
but by a curious piece of serendipity you've pointed me to a solution to a
little problem I've been mulling over for a few days.
I'm currently helping out a friend in California with an application for a
company there. This includes a couple of combo boxes of date/time values
which they want in the format 'mm/dd/yyyy hh:nn AM/PM', defaulting to the
current date/time. Now, while this is being done for their local office the
company is an international one, which I know trades here in the UK too, so I
can't rule out the possibility of the application being used this side of the
pond. Normally I'd try and format date values using "Short Date", "Long
Date", whatever, so that they are shown in the correct local format, but the
format they want can't be done by formatting the value all in one, but at the
same time automatically adjusting to the local format if used over here.
By formatting the date and time separately, as you suggested, this of course
enables me to use:
' requery date combo box to show dates of
' price lists prepared for selected customer
' and show current date/time as default for new price list
Me.cboDateTime.Requery
Me.cboDateTime = Format(VBA.Date, "Short Date") & Format(VBA.Now, "
hh:nn AM/PM")
Similarly in the query for the control's RowSource property I can return the
date/time values from the table formatted in the same way:
SELECT DISTINCT Format(DateTimePrepared,"Short Date") &
Format(DateTimePrepared," hh:nn AM/PM"), DateTimePrepared
FROM CustomerPricings
WHERE CustomerID = Form!cboCustomer))
ORDER BY DateTimePrepared DESC;
I can see this being useful on many occasions. So, instead of chastising
you I owe you a pint!
BTW, during your current sojourn in foreign parts shouldn't you now be
Wayne-I-T, though I suppose in Italian it should be Wayne-A-T?
Ken Sheridan
Stafford, England