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!

Regional settings for date format

Status
Not open for further replies.

GMcFly

Programmer
Oct 2, 2002
48
0
0
NL
Hello everybody!
I made an access database which works very nicely. There is one problem though. When I started running the database on other computers visual basic started reporting errors when I tried to filter a form with criteria the user can enter in the form. I later found out that the problem was with the user's regional settings. Some use "." as a separator others "/". Is there a way to find out what the settings of the user are?

Thanks for your help!

P.S.: to give an example of my problem:
Code:
DoCmd.OutputTo acOutputForm, "frmProducts", acFormatXLS, "s:/filename" & date, True
People using "." as a separator wont have problems, but people with "/" as a separator will because "/" can't be used in a file name.
I'm using the date so the people know what the search criteria for the file was.
 
Use the Format function to apply your own choice of format. Something like Format(date,"YYYYMMDD") would give a file name where the files would appear sorted in date order in Windows Explorer.

Ken
 
I think to interrogate the regional settings you will need to use an api call.

However, it is probably simpler to take control of the date function, & assign it to a string. Loop through the string, replacing the '/' with another character.
e.g.

Dim strDate As String
Dim pos As Integer
Const DATE_SEPERATOR As String = "_"

strDate = Date

Do
pos = InStr(strDate, "/")
If pos > 0 Then
strDate = Left(strDate, pos - 1) & DATE_SEPERATOR & Mid(strDate, pos + 1)
End If
Loop While pos > 0
James Goodman MCP
 
Stupid me! That easy! Thanks for your help guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top