CanNeverThinkOfaName
Programmer
I am trying to use a date field input on a Data Access Project form as a filter for opening a report, but this only works when the date is in American Format ie. mm/dd/yyyy. I am based in the United Kingdom, and would prefer not to have the format of the field on my form set as American, so is there any function in VBA to convert from Bitish to American date format behind the scenes?
If Me.txtJobStartDate = "" Or IsNull(Me.txtJobStartDate) Or Me.txtJobEndDate = "" Or IsNull(Me.txtJobEndDate) Then
MsgBox "Please insert Start and End Date."
Else
stDocName = "rptICTReportsJobCompleted"
stLinkCriteria = "[Job_actioned] = 0 and [job_date_entered] between " & "'" & Me.txtJobStartDate & "' and '" & Me.txtAmericanEndDate.Text & "'"
If stLinkCriteria <> "" Then
sconn = "Driver={SQL Server}; Server=ECONPWRSQL1;" _
& "Database=BTS Project Management;Trusted_Connection=Yes;"
cn.Open sconn
ssql = "SELECT * FROM dbo.[qryICTJobsInternal] where " & stLinkCriteria
rs.Open ssql, cn, adOpenStatic
If rs.RecordCount = 0 Then
MsgBox "These search criteria return no records, please select again."
Else
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
End If
rs.Close
cn.Close
End If
End If
If Me.txtJobStartDate = "" Or IsNull(Me.txtJobStartDate) Or Me.txtJobEndDate = "" Or IsNull(Me.txtJobEndDate) Then
MsgBox "Please insert Start and End Date."
Else
stDocName = "rptICTReportsJobCompleted"
stLinkCriteria = "[Job_actioned] = 0 and [job_date_entered] between " & "'" & Me.txtJobStartDate & "' and '" & Me.txtAmericanEndDate.Text & "'"
If stLinkCriteria <> "" Then
sconn = "Driver={SQL Server}; Server=ECONPWRSQL1;" _
& "Database=BTS Project Management;Trusted_Connection=Yes;"
cn.Open sconn
ssql = "SELECT * FROM dbo.[qryICTJobsInternal] where " & stLinkCriteria
rs.Open ssql, cn, adOpenStatic
If rs.RecordCount = 0 Then
MsgBox "These search criteria return no records, please select again."
Else
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
End If
rs.Close
cn.Close
End If
End If