M
mikefitzge
I'm getting the error "The OpenForm action was canceled" when I click
on the button to open a form. When I try to open the form in the
database window I get the following error:
"The expression On Open you entered as the event property setting
produced the following error:
*The expression may not result in the name of a macro, the name of
a user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event or
macro."
I have the following code on the On Open event of the form:
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
Me.dtmDateConcreteCount.SetFocus
Me.cmdCount.Visible = True
Dim DateCount As Integer
DateCount = 0
Set rst = CurrentDb.OpenRecordset("SELECT
tblConcreteStatus.dtmDateConcreteCount FROM tblConcreteStatus")
Do Until rst.EOF = True
If rst!dtmDateConcreteCount = Date Then DateCount = DateCount + 1
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
If DateCount = 1 Then
Me.lblCountDone.Visible = True
Me.lblCountNotDone.Visible = False
ElseIf DateCount = 0 Then
Me.lblCountDone.Visible = False
Me.lblCountNotDone.Visible = True
Else
MsgBox ("You may have more than one Date Count for the same
day. Contact Mike about fixing this.")
End If
End Sub
dtmDateConcreteCount, cmdCount, lblCountDone, and lblCountNotDone are
all controls on the form.
Is there a problem in my code I'm not seeing? Or could the problem be
somewhere else? Any help would be appreciated.
Thanks,
Mike.
on the button to open a form. When I try to open the form in the
database window I get the following error:
"The expression On Open you entered as the event property setting
produced the following error:
*The expression may not result in the name of a macro, the name of
a user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event or
macro."
I have the following code on the On Open event of the form:
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
Me.dtmDateConcreteCount.SetFocus
Me.cmdCount.Visible = True
Dim DateCount As Integer
DateCount = 0
Set rst = CurrentDb.OpenRecordset("SELECT
tblConcreteStatus.dtmDateConcreteCount FROM tblConcreteStatus")
Do Until rst.EOF = True
If rst!dtmDateConcreteCount = Date Then DateCount = DateCount + 1
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
If DateCount = 1 Then
Me.lblCountDone.Visible = True
Me.lblCountNotDone.Visible = False
ElseIf DateCount = 0 Then
Me.lblCountDone.Visible = False
Me.lblCountNotDone.Visible = True
Else
MsgBox ("You may have more than one Date Count for the same
day. Contact Mike about fixing this.")
End If
End Sub
dtmDateConcreteCount, cmdCount, lblCountDone, and lblCountNotDone are
all controls on the form.
Is there a problem in my code I'm not seeing? Or could the problem be
somewhere else? Any help would be appreciated.
Thanks,
Mike.