Hi everyone
So I'm back from a brief hiatus and upon opening access, I noticed something very odd. I have a datasheet in split-form view and it's data is based off a query which extracts a number of columns from the main table and one of the date fields called InsuranceExpiryDate is displaying odd numbers (e.g. -288175) instead of a date (e.g. 1/2/2012) whenever this is opened in datasheet view. Before leaving, I included a button for reports that would filter on the two date fields (InsuranceExpiryDate and AAFinalDate) and a check box for a yes/no field. Initially, I was trying to get the report to filter between two date ranges and whether the user checked the box for WSIB. For the most part I believe this has worked. Here's the VBA:
However, I think the problem might be somewhere here because the dates were displayed just fine prior. If anyone has any suggestions or possible solutions, that would be much appreciated!
So I'm back from a brief hiatus and upon opening access, I noticed something very odd. I have a datasheet in split-form view and it's data is based off a query which extracts a number of columns from the main table and one of the date fields called InsuranceExpiryDate is displaying odd numbers (e.g. -288175) instead of a date (e.g. 1/2/2012) whenever this is opened in datasheet view. Before leaving, I included a button for reports that would filter on the two date fields (InsuranceExpiryDate and AAFinalDate) and a check box for a yes/no field. Initially, I was trying to get the report to filter between two date ranges and whether the user checked the box for WSIB. For the most part I believe this has worked. Here's the VBA:
Code:
Option Compare Database
Option Explicit
Private Sub cmdAAReport_Click()
Dim strCriteria As String
If Not IsNull(Me.txtStartDate) Then
strCriteria = " And AAFinalDate >= #" & _
Format(Me.txtStartDate, "yyyy-mm-dd") & "#"
End If
If Not IsNull(Me.txtEndDate) Then
strCriteria = strCriteria & " And AAFinalDate < #" & _
Format(Me.txtEndDate + 1, "yyyy-mm-dd") & "#"
End If
' remove leading ' And '
strCriteria = Mid(strCriteria, 6)
' open report
DoCmd.OpenReport "rptCriteriaAA", _
View:=acViewPreview, _
WhereCondition:=strCriteria
End Sub
Private Sub cmdreportIE_Click()
Dim strCriteria As String
If Not IsNull(Me.txtStartDate) Then
strCriteria = " And InsuranceExpiryDate >= #" & _
Format(Me.txtStartDate2, "yyyy-mm-dd") & "#"
End If
If Not IsNull(Me.txtEndDate) Then
strCriteria = strCriteria & " And InsuranceExpiryDate < #" & _
Format(Me.txtEndDate2 + 1, "yyyy-mm-dd") & "#"
End If
' remove leading ' And '
strCriteria = Mid(strCriteria, 6)
' open report
DoCmd.OpenReport "rptCriteriaAA", _
View:=acViewPreview, _
WhereCondition:=strCriteria
End Sub
However, I think the problem might be somewhere here because the dates were displayed just fine prior. If anyone has any suggestions or possible solutions, that would be much appreciated!
Attachments
Last edited: