PDA

Click to See Complete Forum and Search --> : Date proble,


aamer
Nov 11th, 2000, 09:23 AM
Hi there,
I am facing a problem while using Visual Basic version 6, Service Pack 3.
My database is in MS Access and when I try to store date in the date field
of the database, I get the the conversion problem while diplaying date in
the Mask Edit field on the form; date displays in the format that
is set in the regional settings of the Windows Control Panel. Can you help
me in displaying the date field irrespective of the regional settings
in dd/mm/yyyy format?

parksie
Nov 11th, 2000, 09:57 AM
Why not set the Regional Settings up properly? The idea of displaying the date is that it is in the local format.

In Access, I think there's a way to change the date format, will clarify in a few moments...

honeybee
Nov 12th, 2000, 10:19 AM
I had exactly the same problem when I tried to replace all textboxes on my form with the Masked Edit box. Actually you can try a number of ways here:

1. Retrieve the date from the Access database, use the VB Format() function to format it into 'dd/mm/yyyy' and show it.

2. Retrieve the date from the Access database in such a way that it is already formatted in 'dd/mm/yyyy' format, using SQL date conversion functions (of which, sadly I am not an expert.)

There is a third solution of using the Mask property of the editbox control, but I am not too sure whether it supports dd/mm/yyyy. If it does, you can assign the date value to the box, and then set the Mask property. Or if you have already set the Mask property, use a temporary variable and write the code as follows:



Dim tmpMask As String
Dim dbDate As Date

' Open recordset etc. etc.
' Fetch the date value into the dbDate variable

tmpMask = MaskEditBox1.Mask
MaskEditBox1.Mask = ""
MaskEditBox1.Text = dbDate
MaskEditBox1.Mask = tmpMask