date and time display without seconds error #Name?

Siegfried

Registered User.
Local time
Tomorrow, 00:39
Joined
Sep 11, 2014
Messages
105
Dear Access experts,

Can you help me out with subject error?
I'm trying to display the date and time entry in the textbox DeliveryDate on my form frmVessels without the seconds, but keep getting #Name? and #Type? errors. I'm spuzzled...:confused:

Made following module:
Code:
Public Function MySpecialDateFormat(ByVal d As Date) As String
MySpecialDateFormat = Format(d, "mm\dd\yyyy")
 If Hour(d) = 0 Or Minute(d) = 0 Then _
 MySpecialDateFormat = MySpecialDateFormat & _
Format(d, " hh:nn ")
End Function

Set in the form frmVessels the control source of the textbox DeliveryDate to:=MySpecialDateFormat([DeliveryDate])

Form frmVessels based on TblVessels
TblVessels: ShipIDPK, DeliveryDate (Data Type Date/Time General Date)

Thanks.
 
Do you want to get the date or time ?

Why not as imply put the format() on the txtBox's controlSource ?
 
Why not format it directly?
Code:
Format([DeliveryDate],"mm/dd/yyyy hh:nn")
 
Dear Smig, I need date with time e.g. 07/11/2015 14:45.
Dear JHB, I've entered the code in the Control Source ofthe Text Box DeliveryDate but when I go to the form the box displays #Name?
 
Dear Smig, I need date with time e.g. 07/11/2015 14:45.
Dear JHB, I've entered the code in the Control Source ofthe Text Box DeliveryDate but when I go to the form the box displays #Name?
If the text control also is named "DeliveryDate" the rename it.
 
I renamed the textbox:
Name:DateOfTakeOver
Control Source: Format([TakeOverDate],"mm/dd/yyyy hh:nn")
Still getting the #Name? error in the texbox on the form?
Box is marked with: This control has an invalid source.
What am I missing?
 
CORRECTION:
I renamed the textbox:
Name: DateOfDelivery
Control Source: Format([TakeOverDate],"mm/dd/yyyy hh:nn")
Still getting the #Name? error in the texbox on the form?
Box is marked with: This control has an invalid source.
What am I missing?
 
Befor I confuse you more. Attached screenshot of the properties.
 

Attachments

  • DeliveryDate.PNG
    DeliveryDate.PNG
    9.6 KB · Views: 106
You're missing the = before Format.
 
Dear JHB thanks for your help, indeed 2 corrections in the code

Control Source: = Format([TakeOverDate];"mm/dd/yyyy hh:nn")
 
Dear JHB thanks for your help, indeed 2 corrections in the code

Control Source: = Format([TakeOverDate];"mm/dd/yyyy hh:nn")
If you've to use the ; depends of from where you're in the wold, US use the ,.
 

Users who are viewing this thread

Back
Top Bottom