A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

form selector



 
 
Thread Tools Display Modes
  #1  
Old October 7th, 2004, 09:22 AM
alan at work
external usenet poster
 
Posts: n/a
Default form selector

I want Access to open a form from an open one and the key
in both cases is the date. For some reason Access ALWAYS
uses the American date format when searching the 'new'
table/form and so can't find the data. Is there a way
around this. ALL PC's are using UK date format.

Below is the Basic subroutine. Do I need to alter/ modify
the [date] bit. Ive used this routine in the past but the
key was always a reference number.

Private Sub Command47_Click()
On Error GoTo Err_Command47_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Check sheet"

stLinkCriteria = "[date]=" & "#" & Me![date] & "#"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command47_Click:
Exit Sub

Err_Command47_Click:
MsgBox Err.Description
Resume Exit_Command47_Click

End Sub


  #2  
Old October 7th, 2004, 09:32 AM
Allen Browne
external usenet poster
 
Posts: n/a
Default

This is how dates are interpreted in Access:

a) In the interface (text box on form, datasheet, or the Criteria in query
design view), the date is interpreted according to your regional settings
(in the Windows Control Panel).

b) In VBA code and SQL strings, the date is interpreted as mm/dd/yyyy,
regardless of your regional settings. This is the only way a piece of code
can be guaranteed to work the same way, no matter where it is executed.

Therefore, you must use the American format when you build the
WhereCondition for your OpenReport, i.e.:
stLinkCriteria = "[date]=" & "#" & Format(Me![date], "mm/dd/yyyy" & "#"

For more information, see:
International Date Formats in Access
at:
http://members.iinet.net.au/~allenbrowne/ser-36.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"alan at work" wrote in message
...
I want Access to open a form from an open one and the key
in both cases is the date. For some reason Access ALWAYS
uses the American date format when searching the 'new'
table/form and so can't find the data. Is there a way
around this. ALL PC's are using UK date format.

Below is the Basic subroutine. Do I need to alter/ modify
the [date] bit. Ive used this routine in the past but the
key was always a reference number.

Private Sub Command47_Click()
On Error GoTo Err_Command47_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Check sheet"

stLinkCriteria = "[date]=" & "#" & Me![date] & "#"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command47_Click:
Exit Sub

Err_Command47_Click:
MsgBox Err.Description
Resume Exit_Command47_Click

End Sub



  #3  
Old October 7th, 2004, 11:19 AM
alan at work
external usenet poster
 
Posts: n/a
Default

Sorted Many thanks saved a lot of head scratching!!!

-----Original Message-----
This is how dates are interpreted in Access:

a) In the interface (text box on form, datasheet, or the

Criteria in query
design view), the date is interpreted according to your

regional settings
(in the Windows Control Panel).

b) In VBA code and SQL strings, the date is interpreted

as mm/dd/yyyy,
regardless of your regional settings. This is the only

way a piece of code
can be guaranteed to work the same way, no matter where

it is executed.

Therefore, you must use the American format when you

build the

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange stLinkCriteria behaviour on command button Anthony Dowd Using Forms 3 August 21st, 2004 03:01 AM
auto entry into second table after update Tony New Users 13 July 9th, 2004 10:42 PM
Creating a Form. Should I use Control or Form Toolbar? Amy General Discussion 7 July 1st, 2004 02:36 PM
synchronizing form and list box Deb Smith Using Forms 8 June 21st, 2004 08:15 PM
Form Doesn't Go To New Record Steve New Users 15 May 16th, 2004 04:33 PM


All times are GMT +1. The time now is 01:00 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.