Dcount expression syntax error

G

Guest

I have developed a database which holds training records.

I would like to have the user notified when the switchboard loads informing
them of the training records which are out of date now and are due in six
months time. If selected a report preview is loaded.

The code below has been added to the Form_load event.

The error message I get is "Runtime error 3075" from the Dcount function in
intStoreB (the six month check)

Syntax error (missing operator) in query expression [Renewal] <= 23 Feb 2007
11:50:04

I am also curious as to how I can retain focus on the Report preview - (less
important. I have tried to resolve this myself for about three hours now and
can't seem to find the right string construction any help you can give would
be gratefully received. Thank you in advance.

Private Sub Form_Load()
'On Load of the switchboard check Courses table for any Courses overdue or
due for Renewal

Dim intStoreA As Integer
Dim intStoreB As Integer
Dim strMonthSix As String

strMonthSix = DateAdd("m", 6, Now())

'Count of Overdue Courses that are past the Expected Renewal Date
intStoreA = DCount("[Renewal]", "Courses", "[Renewal] <=Now()")

'Count of Courses that are due in the next six months
intStoreB = DCount("[Renewal]", "Courses", "[Renewal] <= " & strMonthSix)

'If count of Overdue Courses is zero display switchboard
'Else display message box detailing amount of renewals
'and give the user the option as to whether to view these or not.
If intStoreA = 0 And intStoreB = 0 Then
Exit Sub
Else
If MsgBox("There are " & intStoreA & " courses overdue and " &
intStoreB & _
vbCrLf & "due in the next six months" & _
vbCrLf & "Would you like to see these now?", _
vbYesNo, "You Have courses overdue...") = vbYes Then
DoCmd.Minimize
DoCmd.OpenReport "Courses due for renewal", acPreview
Else
Exit Sub
End If
End If


End Sub
 
E

e.mel

Sometimes access needs #'s to compare dates properly, try:

intStoreB = DCount("[Renewal]", "Courses", "[Renewal] <= #" &
strMonthSix & "#")
 
G

Guest

Thanks very much e.mel that did the trick.

Mollybot

e.mel said:
Sometimes access needs #'s to compare dates properly, try:

intStoreB = DCount("[Renewal]", "Courses", "[Renewal] <= #" &
strMonthSix & "#")


I have developed a database which holds training records.

I would like to have the user notified when the switchboard loads informing
them of the training records which are out of date now and are due in six
months time. If selected a report preview is loaded.

The code below has been added to the Form_load event.

The error message I get is "Runtime error 3075" from the Dcount function in
intStoreB (the six month check)

Syntax error (missing operator) in query expression [Renewal] <= 23 Feb 2007
11:50:04

I am also curious as to how I can retain focus on the Report preview - (less
important. I have tried to resolve this myself for about three hours now and
can't seem to find the right string construction any help you can give would
be gratefully received. Thank you in advance.

Private Sub Form_Load()
'On Load of the switchboard check Courses table for any Courses overdue or
due for Renewal

Dim intStoreA As Integer
Dim intStoreB As Integer
Dim strMonthSix As String

strMonthSix = DateAdd("m", 6, Now())

'Count of Overdue Courses that are past the Expected Renewal Date
intStoreA = DCount("[Renewal]", "Courses", "[Renewal] <=Now()")

'Count of Courses that are due in the next six months
intStoreB = DCount("[Renewal]", "Courses", "[Renewal] <= " & strMonthSix)

'If count of Overdue Courses is zero display switchboard
'Else display message box detailing amount of renewals
'and give the user the option as to whether to view these or not.
If intStoreA = 0 And intStoreB = 0 Then
Exit Sub
Else
If MsgBox("There are " & intStoreA & " courses overdue and " &
intStoreB & _
vbCrLf & "due in the next six months" & _
vbCrLf & "Would you like to see these now?", _
vbYesNo, "You Have courses overdue...") = vbYes Then
DoCmd.Minimize
DoCmd.OpenReport "Courses due for renewal", acPreview
Else
Exit Sub
End If
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

Similar Threads


Top