![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Apologies for posting a question that has been asked and answered many times but its been causing me a lot of grief! I'm using the following code to prepare a (UK) date from a form to be inserted into a table: If IsDate(dFindSite) Then If DateValue(dFindSite) = dFindSite Then FindSite = Format$(dFindSite, "\#dd\/mm\/yyyy\#") End If End If I've used this many times having found the above code on the list previously, however now i get the error "Type-declaration character does not match declared data type" Any ideas where i'm going wrong? Thanks for any suggestions. Paul |
#3
| |||
| |||
|
|
Paul, here's my experience from working with Access in a dmy country: * * International Date Formats in Access at: * *http://allenbrowne.com/ser-36.html Internally, the value is a special kind of real number, where the integer part represents the day, and the fraction the time (as a fraction of a day.) The article explains how the presentation/entry in the interface is not the same as the way a literal date should appear in a VBA statement or SQL string. It's really important to get the difference. I'm not clear what dFindSite and FindSite are in your code. If one of them is an unbound text box, setting the Format *property* of the text box will help Access understands the data type. If FindSite is a field, then forcing the (date/time)? value in dFindSite to become a string (which is what Format$() outputs), and then back to a date value again is unproductive, serving only to increase the chance of a misinterpretation. There is never a valid reason to use: * * "\#dd\/mm\/yyyy\#" when assigning a date value. In a SQL string or criteria, you always need: * * "\#mm\/dd\/yyyy\#" regardless of your local date format. If you don't follow that discussion about data types, post a follow-up indicating what dFindSite and FindSite are. -- 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. "paul" <paulquinlan... (AT) hotmail (DOT) com> wrote in message news:3d5feccb-b3c8-4194-8311-ff7030b1988f (AT) v19g2000yqn (DOT) googlegroups.com... Apologies for posting a question that has been asked and answered many times but its been causing me a lot of grief! I'm using the following code to prepare a (UK) date from a form to be inserted into a table: * *If IsDate(dFindSite) Then * * * *If DateValue(dFindSite) = dFindSite Then * * * * * *FindSite = Format$(dFindSite, "\#dd\/mm\/yyyy\#") * * * *End If * *End If I've used this many times having found the above code on the list previously, however now i get the error "Type-declaration character does not match declared data type" Any ideas where i'm going wrong? Thanks for any suggestions. Paul- Hide quoted text - - Show quoted text - |
#4
| |||
| |||
|
|
There is never a valid reason to use: * * "\#dd\/mm\/yyyy\#" when assigning a date value. In a SQL string or criteria, you always need: * * "\#mm\/dd\/yyyy\#" regardless of your local date format. |
#5
| |||
| |||
|
|
Paul, here's my experience from working with Access in a dmy country: * * International Date Formats in Access at: * *http://allenbrowne.com/ser-36.html Internally, the value is a special kind of real number, where the integer part represents the day, and the fraction the time (as a fraction of a day.) The article explains how the presentation/entry in the interface is not the same as the way a literal date should appear in a VBA statement or SQL string. It's really important to get the difference. I'm not clear what dFindSite and FindSite are in your code. If one of them is an unbound text box, setting the Format *property* of the text box will help Access understands the data type. If FindSite is a field, then forcing the (date/time)? value in dFindSite to become a string (which is what Format$() outputs), and then back to a date value again is unproductive, serving only to increase the chance of a misinterpretation. There is never a valid reason to use: * * "\#dd\/mm\/yyyy\#" when assigning a date value. In a SQL string or criteria, you always need: * * "\#mm\/dd\/yyyy\#" regardless of your local date format. If you don't follow that discussion about data types, post a follow-up indicating what dFindSite and FindSite are. -- 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. "paul" <paulquinlan... (AT) hotmail (DOT) com> wrote in message news:3d5feccb-b3c8-4194-8311-ff7030b1988f (AT) v19g2000yqn (DOT) googlegroups.com... Apologies for posting a question that has been asked and answered many times but its been causing me a lot of grief! I'm using the following code to prepare a (UK) date from a form to be inserted into a table: * *If IsDate(dFindSite) Then * * * *If DateValue(dFindSite) = dFindSite Then * * * * * *FindSite = Format$(dFindSite, "\#dd\/mm\/yyyy\#") * * * *End If * *End If I've used this many times having found the above code on the list previously, however now i get the error "Type-declaration character does not match declared data type" Any ideas where i'm going wrong? Thanks for any suggestions. Paul- Hide quoted text - - Show quoted text - |
#6
| |||
| |||
|
|
There is never a valid reason to use: "\#dd\/mm\/yyyy\#" when assigning a date value. In a SQL string or criteria, you always need: "\#mm\/dd\/yyyy\#" regardless of your local date format. |
#7
| |||
| |||
|
|
Apologies for posting a question that has been asked and answered many times but its been causing me a lot of grief! I'm using the following code to prepare a (UK) date from a form to be inserted into a table: * * If IsDate(dFindSite) Then * * * * If DateValue(dFindSite) = dFindSite Then * * * * * * FindSite = Format$(dFindSite, "\#dd\/mm\/yyyy\#") * * * * End If * * End If I've used this many times having found the above code on the list previously, however now i get the error "Type-declaration character does not match declared data type" Any ideas where i'm going wrong? Thanks for any suggestions. Paul |
![]() |
| Thread Tools | |
| Display Modes | |
| |