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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with the Format Function

Status
Not open for further replies.

BAWC01

Technical User
Nov 23, 2005
79
0
0
CH
Hi

I am trying to format a date, using a wrapper function

Code:
Public Function SetInvDate() As Date
SetInvDate = format(GlobalInvoiceDate, "dd-mm-yy")
End Function

But I have noticed that the format stays in lower case and in black, rather than like Format in uppercase.

What is going on

Phil
 
What is "GlobalInvoiceDate" ? Is it a Date Value or a text string ?
 
lower case and in black???

like avolkert said, If GlobalInvoiceDate is a Date data type, then I would expect 2/24/05 to look like 24-02-05?

Where would you get any text from, and what has forecolor got to do with it?

In other words, "what data type is GlobalInvoiceDate", and what results are you expecting?
 
I think that what Phil says is that this line
SetInvDate = format(GlobalInvoiceDate, "dd-mm-yy")
should look like
SetInvDate = [blue]Format[/blue](GlobalInvoiceDate, "dd-mm-yy")
 
I think the issue is that your function returns a date, not a string. No matter how you format the string within the function, it will still come out converted to a date. Did you mean:
Code:
Public Function SetInvDate() As String
  SetInvDate = format(GlobalInvoiceDate, "dd-mm-yy")
End Function
?
 
If JerryKlmns is correct, then you most likely you have an object, variable, form control ... somewhere within the scope you're programming in, which is named like that. Find that, and rename it, else you're going to have further challenges. You can probably circumvent some of the challenges by prefixing with the library (VBA.Format( ...), but again, renaming the offending "thingie" is probably best.

Roy-Vidar
 
How are ya BAWC01 . . .

In the immediate window type . . .
Code:
[blue]? SetInvDate() [/blue]
. . . and hit enter. [blue]This will reveal the format of the date returned by the function.[/blue] From here you shohld be able to tell if its a problem in the function, or a problem in the object the function value is assigned to . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top