View Full Version : Operation not supported Error


Full_Williams
08-26-2003, 06:03 AM
Hi,

I'm getting "Run time error '3251' Operation is not supported for this type of object" on the:

If ctl.Value <> ctl.oldValue then line.

I'm asking the user if he/she wants to keep the changes made to the form. If not then replace the changes with the old value.

This code was working fine for me until I added tab pages on my form. Any thoughts on what the problem might be.

Any help is appreciated.

Thanks,
Full Williams

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If ctl.Value <> ctl.OldValue Then
ctl.Value = ctl.OldValue
ElseIf IsNull(ctl.OldValue) Then
ctl.Value = ctl.OldValue
ElseIf IsNull(ctl.Value) Then
ctl.Value = ctl.OldValue
End If
End If
If ctl.ControlType = acComboBox Then
If ctl.Value <> ctl.OldValue Then
ctl.Value = ctl.OldValue
ElseIf IsNull(ctl.OldValue) Then
ctl.Value = ctl.OldValue
ElseIf IsNull(ctl.Value) Then
ctl.Value = ctl.OldValue
End If
End If

Next ctl

namliam
08-26-2003, 06:10 AM
Apperently your trying to use .value for the tab which doesnt have .value. For some reason a tab [or anyother control] appears to be either a combo or text box.... Not sure, i never used anything like this....

Hope that helps anyway.

Further i wonder about your code, why not:For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Value = ctl.OldValue
End If
If ctl.ControlType = acComboBox Then
ctl.Value = ctl.OldValue
End If
Next ctlCause who cares if the are different or the same, just reset... Empty or no....

Regards

The Mailman

Full_Williams
08-26-2003, 06:32 AM
Mailman,

Thanks for the response. Good point on taking out the extra code.

The code is now actually stopping on a textbox control which has an expression that can't be edited. The expression is combining FName and LName.

I'm getting closer, any other thoughts.

Thanks for your input.

Full Williams

namliam
08-26-2003, 06:49 AM
Not Offhand...

Full_Williams
08-26-2003, 07:05 AM
Okay I solved the Name issue, at least I think I did. Now is getting caught up on an AutoNumber field. I'm trying to workaround this by using an If Then to identify the control, but it's not working.

Any ideas on how to identify a control. ctl.Name = X doesn't seem to work.

Full Williams

namliam
08-27-2003, 01:13 AM
I tried using the code below and ctl.name (allthought not in the list, this is because ctl is a general control .name is a specific thing....) works just fine....Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acBoundObjectFrame
Case acCheckBox
Case acComboBox
Case acCommandButton
Debug.Print "Button " & ctl.Name
Case acCustomControl
Case acImage
Case acLabel
Debug.Print "Label " & ctl.Name
Case acLine
Case acListBox
Case acObjectFrame
Case acOptionButton
Case acOptionGroup
Case acPage
Case acPageBreak
Case acRectangle
Case acSubform
Case acTabCtl
Case acTextBox
Debug.Print "Texbox " & ctl.Name
Case acToggleButton
Case Else
End Select
Next ctl
This is a total list of ac constants for all controls available ... (taken from the help) you ight not need all, not all may support .name but use F8 to step thru and find which goes where and what will work....

Greeting from holland :)

Regards

The mailman

Full_Williams
08-27-2003, 08:15 AM
This might be a silly question, but how do you get the

Debug.Print "Texbox " & ctl.Name to actually show up on your screen? It's not doing anything for me right now.

So I can't figure out which control is giving me the problem.

Thanks,

Full Williams

Rich
08-27-2003, 08:21 AM
Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name

Full_Williams
08-28-2003, 06:10 AM
Rich,

Thanks for the response. Is this a different method compared to the Debug.Print method?

Also I figured out my problem if anyone's following this thread. I only wanted to check the specific tab's controls for changes so I had to specify by doing this:

Dim pge As Page

Set pge = Me.TabPageName

For Each ctl In pge.Controls
Next ctl

It did the trick.

Thanks for the help.

Full Williams