date and time display without seconds error #Name? (1 Viewer)

Siegfried

Registered User.
Local time
Today, 07:19
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.
 

smig

Registered User.
Local time
Today, 08:19
Joined
Nov 25, 2009
Messages
2,209
Do you want to get the date or time ?

Why not as imply put the format() on the txtBox's controlSource ?
 

JHB

Have been here a while
Local time
Today, 07:19
Joined
Jun 17, 2012
Messages
7,732
Why not format it directly?
Code:
Format([DeliveryDate],"mm/dd/yyyy hh:nn")
 

Siegfried

Registered User.
Local time
Today, 07:19
Joined
Sep 11, 2014
Messages
105
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?
 

JHB

Have been here a while
Local time
Today, 07:19
Joined
Jun 17, 2012
Messages
7,732
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.
 

Siegfried

Registered User.
Local time
Today, 07:19
Joined
Sep 11, 2014
Messages
105
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?
 

Siegfried

Registered User.
Local time
Today, 07:19
Joined
Sep 11, 2014
Messages
105
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?
 

Siegfried

Registered User.
Local time
Today, 07:19
Joined
Sep 11, 2014
Messages
105
Befor I confuse you more. Attached screenshot of the properties.
 

Attachments

  • DeliveryDate.PNG
    DeliveryDate.PNG
    9.6 KB · Views: 57

JHB

Have been here a while
Local time
Today, 07:19
Joined
Jun 17, 2012
Messages
7,732
You're missing the = before Format.
 

Siegfried

Registered User.
Local time
Today, 07:19
Joined
Sep 11, 2014
Messages
105
Dear JHB thanks for your help, indeed 2 corrections in the code

Control Source: = Format([TakeOverDate];"mm/dd/yyyy hh:nn")
 

JHB

Have been here a while
Local time
Today, 07:19
Joined
Jun 17, 2012
Messages
7,732
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

Top Bottom