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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |