The Following Code Is Working Perfectly with number fields.
Please note "LoginIDNo" is Number Field, where as I want to change this to Text Field, e.g David instead of 2 (this is login id of david)
The Text Field I want to use is [EntryPLogin By] How and what changes are required to do this. Help is needed.
Private Sub cmdOpenReportDataop_Click()
On Error GoTo Err_Handler
Const REPORTNAME = "General Purchase wo Varification"
Const MESSAGETEXT = _
"A customer and both a start and end date must be selected."
Dim strCriteria As String
Dim strDateFrom As String, strDateTo As String
' make sure a customer and both dates are selected
If Not IsNull(Me.CboDataOp) And Not IsNull(Me.cboDateFrom) _
And Not IsNull(Me.cboDateTo) Then
strDateFrom = "#" & Format(Me.cboDateFrom, "yyyy-mm-dd") & "#"
strDateTo = "#" & Format(DateAdd("d", 1, Me.cboDateTo), "yyyy-mm-dd") & "#"
' build string expression to filter report
' to selected customer and data range
strCriteria = "LoginIDNo = " & Me.CboDataOp & _
" And PurDate >= " & strDateFrom & " And PurDate < " & strDateTo
' open report filtered to selected customer and date range
DoCmd.OpenReport REPORTNAME, _
View:=acViewPreview, _
WhereCondition:=strCriteria
Else
MsgBox MESSAGETEXT, vbExclamation, "Invalid operation"
End If
Exit_Here:
Exit Sub
Err_Handler:
MsgBox Err.Description, vbExclamation, "Error"
Resume Exit_Here
End Sub