Problem with date format

  • Thread starter Benedikt Friðbjörnsson
  • Start date
B

Benedikt Friðbjörnsson

Hi Can anyone help me with this code. The problem is that in my country the
date format is dd.mm.yyyy. When I run this code is I get "Syntax error in
date in query expression '([MyDate] >= #3.11.2008#'. When I change the
format in my computer to dd/mm/yyyy the code is OK.

best regards
Benedikt
IT Samherji
Iceland


Option Compare Database
Option Explicit

Private Sub cmdApplyFilter_Click()
Dim strFilter As String
Dim blnFilterOn As Boolean
Dim strCriteria As String

strCriteria = "Criteria: "

If Nz(Me.cboNName, vbNullString) <> vbNullString Then
strFilter = " AND [NName] = '" & Me.cboNName & "'"
strCriteria = strCriteria & "Name = " & cboNName
End If

If Nz(Me.txtStartDate, vbNullString) <> vbNullString And
Nz(Me.txtEndDate, vbNullString) <> vbNullString Then
If Me.txtStartDate > Me.txtEndDate Then
MsgBox "Start Date Cannot Be Greater Than End Date",
vbInformation
Exit Sub
End If
End If
If Nz(Me.txtStartDate, vbNullString) <> vbNullString Then
strFilter = strFilter & " AND [MyDate] >= #" & Me.txtStartDate & "#"
strCriteria = strCriteria & vbCrLf & "Begin Date: " &
Me.txtStartDate
End If

If Nz(Me.txtEndDate, vbNullString) <> vbNullString Then
strFilter = strFilter & " AND [MyDate] <= #" & Me.txtEndDate & "#"
strCriteria = strCriteria & vbCrLf & "End Date: " & Me.txtEndDate
End If

If strFilter <> vbNullString Then
strFilter = Mid(strFilter, 6)
Me.txtCriteria = strCriteria
Reports("rptForPopUp").Filter = strFilter
Reports("rptForPopUp").FilterOn = True
Else
MsgBox "Enter some criteria", vbInformation
End If


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top