Date Criteria In VB Recordsource? HOW! 
Author Message
 Date Criteria In VB Recordsource? HOW!

This is quite a simple one, which I am sure you can all solve.
Basically, I have written a VB application that accesses MS ACCESS
2.0, dBASE III/IV and Paradox files. This is fine and well, and I can
search any file using any criteria except dates, even if the field is
a date field. I am using something like

data1.recordsource = "select * from transactions where inv_date >
31/12/95"

I get no errors or anything, it just doesnt't find any records, or it
finds all of them. I have tried putting the date in single quotes,
dd/mm/yy, yy/mm/dd, mm/dd/yy format, but nothing seems to work. I must
be failing somewhere in a very simple way. PLEASE HELP ME!!!

Unending thanks in advance,



Sat, 04 Apr 1998 03:00:00 GMT  
 Date Criteria In VB Recordsource? HOW!

Quote:
>This is quite a simple one, which I am sure you can all solve.
>Basically, I have written a VB application that accesses MS ACCESS
>2.0, dBASE III/IV and Paradox files. This is fine and well, and I can
>search any file using any criteria except dates, even if the field is
>a date field. I am using something like
>data1.recordsource = "select * from transactions where inv_date >
>31/12/95"
>I get no errors or anything, it just doesnt't find any records, or it
>finds all of them. I have tried putting the date in single quotes,
>dd/mm/yy, yy/mm/dd, mm/dd/yy format, but nothing seems to work. I must
>be failing somewhere in a very simple way. PLEASE HELP ME!!!

Try placing # on either end of the date


Sun, 05 Apr 1998 03:00:00 GMT  
 Date Criteria In VB Recordsource? HOW!

Quote:

>data1.recordsource = "select * from transactions where inv_date >
>31/12/95"
>I get no errors or anything, it just doesnt't find any records, or it
>finds all of them. I have tried putting the date in single quotes,
>dd/mm/yy, yy/mm/dd, mm/dd/yy format, but nothing seems to work. I must
>be failing somewhere in a very simple way. PLEASE HELP ME!!!

Dates must be enclosed between "#" characters.
I hope that the following code will help you.

Sub CmdSeleziona_Click ()
Dim SQLText, Date1, Date2 As String

'If date is in the dd-mm-yy,
' I get an error when FrmPatenti.DtAnag.Refresh,
'so I have to change it.
Date1 = Format$(MkeDal.Text, "mm-dd-yy")
Date2 = Format$(MkeAl.Text, "mm-dd-yy")
'MkeDal and MkeAl are contents of MaskEdit controls

SQLText = "SELECT * FROM PATENTI WHERE (DAT_SCAD BETWEEN #"
SQLText = SQLText & Date1
SQLText = SQLText & "# AND #"
SQLText = SQLText & Date2
SQLText = SQLText & "#) ORDER BY COGN, NOM "

' FrmPatenti is another form, DtAnag is a data control
FrmPatenti.DtAnag.RecordSource = SQLText

'Activate, VERY IMPORTANT or you will never see any change
FrmPatenti.DtAnag.Refresh

Unload Me

End Sub

Giuseppe Girardelli



Fri, 10 Apr 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Date Criteria In VB Recordsource? HOW!

2. VB5 Data Control - Recordsource criteria from other control

3. Problem with dates and RecordSource Property

4. RecordSource and dBase Dates

5. Concatenation of complex date criteria Acc97

6. Calling values from table based on date range criteria

7. dlookup and date field criteria

8. Find a Date for query criteria

9. Access97: Query criteria - dates

10. Date time format in Find criteria.

11. SQLwith Date criteria - Help please.

12. (CRY)stal Pro Select Criteria - Date

 

 
Powered by phpBB® Forum Software