Need some VB help to change date to letters.

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

I have the vb code below in my form.
On the form I have the date in a field called "Del"
I have a textbox called "LP" with the following in the default value
"=DateToChars(Date())"

I need to change this code from showing todays date to the date that is
stored in the "Del" field otherwise it will always show the current date and
not the date the product was received.
thank you
Michael





Public Function DateToChars(dtmDate As Date) As String

Dim astrCodes(9) As String
Dim strDate As String
Dim lngChar As Long
Dim strOutput As String

astrCodes(0) = "L"
astrCodes(1) = "A"
astrCodes(2) = "B"
astrCodes(3) = "C"
astrCodes(4) = "D"
astrCodes(5) = "E"
astrCodes(6) = "F"
astrCodes(7) = "G"
astrCodes(8) = "H"
astrCodes(9) = "I"
strDate = Format$(dtmDate, "ddmmyyyy")
For lngChar = 1 To Len(strDate)
strOutput = strOutput & astrCodes(Val(Mid$(strDate, lngChar, 1)) Mod
10)
Next lngChar
DateToChars = strOutput

End Function
 
thank you Sandra..
michael
Sandra Daigle said:
Just change the expression to "=DateToChars([Del])"
--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I have the vb code below in my form.
On the form I have the date in a field called "Del"
I have a textbox called "LP" with the following in the default value
"=DateToChars(Date())"

I need to change this code from showing todays date to the date that
is stored in the "Del" field otherwise it will always show the
current date and not the date the product was received.
thank you
Michael





Public Function DateToChars(dtmDate As Date) As String

Dim astrCodes(9) As String
Dim strDate As String
Dim lngChar As Long
Dim strOutput As String

astrCodes(0) = "L"
astrCodes(1) = "A"
astrCodes(2) = "B"
astrCodes(3) = "C"
astrCodes(4) = "D"
astrCodes(5) = "E"
astrCodes(6) = "F"
astrCodes(7) = "G"
astrCodes(8) = "H"
astrCodes(9) = "I"
strDate = Format$(dtmDate, "ddmmyyyy")
For lngChar = 1 To Len(strDate)
strOutput = strOutput & astrCodes(Val(Mid$(strDate, lngChar,
1)) Mod 10)
Next lngChar
DateToChars = strOutput

End Function
 
Back
Top