3251- Oeration is not supported for this type of object

koolwaters

Active Member
Joined
May 16, 2007
Messages
403
Hello!

I have the code below in the Before Update event of a form in my database, but I get "3251- Oeration is not supported for this type of object" and I am not sure why.

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo ErrorHandler
Dim i As Integer

    If IsNull(Me.StartDate) = True Then
        i = MsgBox("Please enter the Program Start Date.", vbCritical, gstrAppTitle)
        Me.StartDate.SetFocus
        DoCmd.CancelEvent
        Exit Sub
    End If

    If IsNull(Me.EndDate) = True Then
        i = MsgBox("Please enter the Program Completion Date.", vbCritical, gstrAppTitle)
        Me.EndDate.SetFocus
        DoCmd.CancelEvent
        Exit Sub
    End If

    If IsNull(Me.ApplicationDate) = True Then
        i = MsgBox("Please enter the Application Date.", vbCritical, gstrAppTitle)
        Me.ApplicationDate.SetFocus
        DoCmd.CancelEvent
        Exit Sub
    End If

    If IsNull(Me.ImmediateManager) = True Then
        i = MsgBox("Please enter or choose the applicant's Immediate Manager.", vbCritical, gstrAppTitle)
        Me.ImmediateManager.SetFocus
        DoCmd.CancelEvent
        Exit Sub
    End If

    If IsNull(Me.DateSent) = True Then
        i = MsgBox("Please enter the date application was sent for approval.", vbCritical, gstrAppTitle)
        Me.DateSent.SetFocus
        DoCmd.CancelEvent
        Exit Sub
    End If

    If (Me.Decision.Column(1) = "Approved") Then
        If IsNull(Me.BondingStartDate) = True Then
        i = MsgBox("Please enter the Bonding Start Date for this application.", vbCritical, gstrAppTitle)
        Me.BondingStartDate.SetFocus
        DoCmd.CancelEvent
        Exit Sub
        End If
    End If

    If (Me.Decision.Column(1) = "Approved") Then
        If IsNull(Me.BondingEndDate) = True Then
        i = MsgBox("Please enter the Bonding End Date for this application.", vbCritical, gstrAppTitle)
        Me.BondingEndDate.SetFocus
        DoCmd.CancelEvent
        Exit Sub
        End If
    End If
    
    If (Me.LevelOfStudy.Column(1) = "Professional Studies") Then
        If IsNull(Me.ProfessionalStudy) = True Then
        i = MsgBox("You have entered Professional Study as the Level of Study." & vbCrLf & vbCrLf & "Please enter the Professional Study.", vbCritical, gstrAppTitle)
        Me.ProfessionalStudy.SetFocus
        Me.ProfessionalStudy.Dropdown
        DoCmd.CancelEvent
        Exit Sub
        End If
    End If

ErrorHandler:
    
    If Err.Number = 2001 Then
        Else
        MsgBox Err.Description
    End If

End Sub

Can someone help me please.

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Have you tried stepping through the code to see the line causing the failure?

You could put a breakPoint on the first If, and then, when the breakPOint is reached, step through the code (F8) to see what exactly Access doesn't like.

Incidentally, you are assigning the Msgbox to an Integer...... is that kosher??? I have seen that as I recall.
 
Upvote 0
I'm not sure what the problem is. I'd attempt the following investigations:

1)
Comment out all of the set focus lines (just to remove a variable), and the dropdown for professional studies. If the error is something about focusing on a control we can worry about it later.

2)
Comment out the error handling until the form's been fully tested - you might find the exact line it's crashing on (as noted above).

2)
If it still errors, don't use:
DoCmd.CancelEvent
Instead just:
Cancel = True
I don't know if this is a problem or not - it's the first I've seen docmd.CancelEvent used this way. Since it's new to me I've mentioned it as a possibility.

Should be fine with msgbox and the integer variable, by the way. Msgbox will probably return a default value of (the named integer constant) vbOk. Though since you're not doing anything with it its unnecessary.
 
Upvote 0
Hi Xenou,

I replaced the docmd.CancelEvent with Cancel=True and I am no longer getting the error.

Thanks as usual for the responses.
 
Upvote 0

Forum statistics

Threads
1,222,013
Messages
6,163,390
Members
451,834
Latest member
tomtownson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top