Help with runtime error 2448 you can't assign a value to this object

Frantic

New Member
Joined
Oct 15, 2007
Messages
30
Hi folks

Please can someone tell me where I am going wrong to get this error?

I have a main form (frmsearch) which has controls on it that are used to search the records in the subform (frmentries). The subform runs off a query which looks to frmsearch to get the criteria. The controls on frmsearch are a combination of text boxes and combo boxes, and date fields which can be filled in using a calendar contol.

There are two command buttons, one to execute the search, and another to clear all search fields to start again. It's in the clear search command that I get the error.

This is the on click event, the debugger highlights "ctl.value = null":

Private Sub cmdclearsearch_Click()
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, ocxcalendar2
ctl.Value = Null
Case acCheckBox
ctl.Value = False
End Select
Next ctl
Me.Refresh
Form_frmentries.Requery

End Sub

What am I missing here?!

Many thanks
F
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Just prior to the line "ctl.Value = Null" put "Debug.Print ctl.name" (without quotes). Then run the code. When it jams on the line look in the immediate window and see the last control listed. That control cannot be set to null for some reason, probably because the underlying field is set to not accept nulls.

hth,

Rich
 
Upvote 0
Thanks, but I've just figured it out. I saw another post on a different forum about something similar that said to check if any of the controls had control sources. I was convinced none of mine had but I realised I'd put in another text box to test something out and then forgot about it. That control had a control source so now I've deleted it and it works now!

Thanks anyway!

F
 
Upvote 0

Forum statistics

Threads
1,214,385
Messages
6,119,209
Members
448,874
Latest member
b1step2far

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