dkmoreland
Registered User.
- Local time
- Today, 10:11
- Joined
- Dec 6, 2017
- Messages
- 129
Would someone be willing to point out my error in this DCount expression (highlighted in red)? I can't see the mismatch.
Code:
Private Sub TxtEndDate_AfterUpdate()
Dim dStart As Date
Dim dEnd As Date
Dim strSQL As String
Dim lNumJobs As Long
On Error GoTo ErrProc
Set db = CurrentDb()
Set rs = db.OpenRecordset("Production Raw Data")
dStart = Me.TxtStartDate
dEnd = Me.TxtEndDate
Debug.Print dStart
Debug.Print dEnd
strSQL = "SELECT [Production raw data].start_date, [Production raw data].end_date, [Production raw data].jobnum, [Production raw data].jobname" _
& " FROM [Production raw data]" _
& " WHERE ((([Production raw data].start_date) = dStart And [Production raw data].[enddate] = dEnd"
Debug.Print strSQL
[COLOR="Red"][B]lNumJobs = DCount("*", "Production raw data", "[start_date]='" & dStart & "' AND [end_date]='dEnd'")[/B][/COLOR]
Debug.Print lNumJobs
ExitProc:
Set db = Nothing
Exit Sub
ErrProc:
Select Case Err.Number
Case 462 'excel not open
Set appExcel = New Excel.Application
Resume Next
Case 3125
MsgBox "The selected workbook is not the correct format.", vbOKOnly
Resume ExitProc
Case 3201
MsgBox "Job Prefix is not valid. Please add the new prefix to the prefix list. Import was cancelled.", vbOKOnly
Resume ExitProc
Case Else
MsgBox Err.Number & "--" & Err.Description
Resume ExitProc
Resume Next
End Select
End Sub