Dim s As String
If Nz(Me.txtRecordID, "") <> "" Then
s = s & " [RecordID] Like '*" & Me.txtRecordID & "*'"
End If
If Nz(Me.txtPRn, "") <> "" Then
If Len(s) > 0 Then
s = s & " AND "
End If
s = s & " [PRn] Like '*" & Me.txtPRn & "*'"
End If
If Nz(Me.txtSKUn, "") <> "" Then
If Len(s) > 0 Then
s = s & " AND "
End If
s = s & " [SKUn] Like '*" & Me.txtSKUn & "*'"
End If
If Nz(Me.txtRevisionDate, "") <> "" Then
If Len(s) > 0 Then
s = s & " AND "
End If
s = s & " [RevisionDate] Like '*" & Me.txtRevisionDate & "*'"
End If
If Len(s) > 0 Then
s = "SELECT * FROM [tblRecords] WHERE " & s & " Order by [RecordID]"
Else
s = "SELECT * FROM [tblRecords] " & " Order by [RecordID]"
End If
DoCmd.OpenForm "frmRecordsHeader", acNormal, , , acFormReadOnly, acWindowNormal
Forms!frmRecordsHeader.Form!subfrmRecordsDS.Form.RecordSource = s
If Nz(Me.txtRevisionDate, "") <> "" Then
If Len(s) > 0 Then
s = s & " AND "
End If
s = s & " [RevisionDate] Like '*" & Me.txtRevisionDate & "*'"
End If
If Nz(Me.txtRevisionDate, "") <> "" Then
If Len(s) > 0 Then
s = s & " AND "
End If
s = s & " [RevisionDate] Like '*" & Me.txtRevisionDate & "*'"
End If
If Nz(Me.txtStartDate, "") <> "" Then
If Len(s) > 0 Then s = s & " AND "
s = s & "([RevisionDate] >= #" & Me.txtStartDate & "#)"
End If
'I use the following syntax to make certain that if the RevisionDate field contains a time
'component, then all of the records pertaining to that date are included in the results.
If Nz(Me.txtEndDate, "") <> "" Then
If Len(s) > 0 Then s = s & " AND "
s = s & "([RevisionDate] < #" & DateAdd("d", 1, Me.txtEndDate) & "#)"
End If
ASKER
s = s & " [RevisionDate] BETWEEN #" & Format([txtStartDate], "yyyy\/mm\/dd") & "# AND #" & Format([txtEndDate], "yyyy\/mm\/dd") & "#"
/gustav
ASKER
If Nz(Me.txtStartDate, "") <> "" Then
If Len(s) > 0 Then s = s & " AND "
s = s & "([RevisionDate] >= #" & Me.txtStartDate & "#)"
End If
If Nz(Me.txtEndDate, "") <> "" Then
If Len(s) > 0 Then s = s & " AND "
s = s & " [RevisionDate] BETWEEN #" & Format([txtStartDate], "yyyy\/mm\/dd") & "# AND #" & Format([txtEndDate], "yyyy\/mm\/dd") & "#"
End If
ASKER
ASKER
If Nz(Me.txtEndDate, "") <> "" Then
If Len(s) > 0 Then s = s & " AND "
' s = s & " [RevisionDate] BETWEEN #" & Format([txtStartDate], "yyyy\/mm\/dd") & "# AND #" & Format([txtEndDate], "yyyy\/mm\/dd") & "#"
s = s & " [RevisionDate] BETWEEN #" & Format([txtStartDate], "mm\/dd\/yyyy") & "# AND #" & Format([txtEndDate], "mm\/dd\/yyyy") & "#"
End If
If Nz(Me.txtStartDate, "") <> "" And Nz(Me.txtEndDate, "") <> "" Then
If Len(s) > 0 Then
s = s & " AND "
End If
s = s & " [RevisionDate] BETWEEN #" & Format([txtStartDate], "yyyy\/mm\/dd") & "# AND #" & Format([txtEndDate], "yyyy\/mm\/dd") & "#"
End If
/gustav
ASKER
ASKER
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
TRUSTED BY
ASKER
Open in new window