Easystart wrote:
Quote:
Hi,
>
Sorry for my English. English is not my native tougue.
>
I am working in MS Access 2000 with a SQLServer 2000 Backend database.
MS Access 2000 is my GUI front end that has SQLServer linked tables in
it. One of my forms has two TEXT BOX controls formated as Short Date.
The form is binded to a linked table. The linked tables has about 7
records and one of the control is binded to a table field. These two
controls displays the date correctly as 01/07/2006 and 31/07/2006 (I am
running Windows XP, my regional setting is set to English Australia,
location is set to Australia, language for non-Unicode programs is set
to English Australia, and my date format is set to d/MM/YYYY) when the
form is running. I have some VBA code behind the form to print out
these two dates to a text file. The dates show up as 30/12/2005 and
30/01/2006. I really do not know why these dates are totally different.
Here's my VBA code:
>
Open "C:\Results.txt" For Output Access Write Lock Write As #1
Print #1, "GL run from "; Me.txtFromDate; " to "; Me.txtToDate
Print #1, ""
::
::
Close #1
>
I am hoping some one has come across with this problem.
>
Thanks in advance,
>
Easystart
I cannot duplicate your results. It seems that something obvious
(exchanging day and month positions;
allowing for SQL-Server day zero to be two days later than VBA
[1900-01-01 as opposed to 1899-12-30];
the "#" character being interpreted to mean number by the print command
rather that date-number)
isn't jumping out here.
I note that, depending upon rounding, the error dates are one half year
earlier than the correct dates. Are you doing anything with six months,
half a year in this procedure or any procedure connected with this
form?
I suggest that you run
Open "C:\Results.txt" For Output Access Write Lock Write As #1
Debug.Print "GL run from "; Me.txtFromDate; " to "; Me.txtToDate
Debug.Print "GL run from "; Clng(Me.txtFromDate); " to ";
CLng(Me.txtToDate)
Print #1, "GL run from "; Me.txtFromDate; " to "; Me.txtToDate
.....
to see if the values appearing in the Immediate Window will shed some
light on what's going wrong. I would also be more explicit as in
Me.txtFromDate.Value.
or
Format(Me.txtFromDate.Value, "yyyy-mm-dd")