How to supress "openform action was cancelled" message

  • Thread starter Thread starter PeterJ
  • Start date Start date
P

PeterJ

I have never learnt VB so what I know is all through trial, error and luck
:¬) Please bear that in mind if you answer my question.

I have a form used by an administrator to book training courses. When he/she
submits the request the system checks to see if there are already others
booked on the course. If so, then another form opens showing the number of
places still available. If there are no previous bookings (i.e. this is the
very first) then I skip the form with the place count on it and go directly
to a bookings confirmation form.

I use the "on Open" property to decide whether to skip the second form or not.

Everything works absolutely fine but if the form is skipped then the message
"OpenForm action was cancelled" appears. How can I suppress this message? As
you can see below, I've tried "DoCmd.SetWarnings False" but to no avail.

My "onOpen" code is:

Private Sub Form_Open(Cancel As Integer)
DoCmd.SetWarnings False
If Me.Recordset.RecordCount = 0 Then
Cancel = True
DoCmd.OpenQuery "Add Booking Details to Table", acNormal, acEdit
DoEvents
DoCmd.OpenForm "Booking Confirmation Details"
End If
End Sub

Any help much appreciated

Peter
 
Daniel,

Thanks for the quick reply.

No line is highlighted as what happens isn't actually an error. The "on
Open" code is doing exactly what I want it to do i.e. it skips over the
second form if no previous bookings exist and opens the "Bookings
Confirmation" form.

All that is happening is that when the code has run the first form closes
(as it should) the "Bookings Confirmation" form opens (as it should) and the
"openform action was cancelled" message appears. There is no error code
associated with it so I can't input anything in the " If Err.Number " bit of
your error handler code
 
Back
Top