Runtime Error 382: “Property Set can't be executed at run time,” explained and fixed
Error 382, “Property Set can't be executed at run time”, fires when running code tries to assign an object reference to a property that does not accept a Property Set while the program is running. Some properties are design-time only by design: they exist so a developer can configure a control or class in the properties window, and the underlying object refuses to rewire them mid-run. The assignment statement is syntactically right; the property's contract says no, not now. The fix is architectural: set the property at design time, or use a property that is settable at run time.
For people who just run the program
- This error is aimed at the tool's developer. It appears in component and control-based programs when running code tries to swap an object a property points to, something the component does not allow after start-up.
- Note the feature in use. Features that reconfigure connections, data sources, or embedded objects at run time are the usual call sites.
- Restarting does not help. The restriction is built into the component; the same feature will hit it every time.
- Pass the number to the maintainer. Error 382 names its own remedy: the assignment must move to design time or to a different property.
For people who write the code
- Check the property's documented availability. Control and class documentation marks properties as design-time, run-time, or both. If the object-valued property you are assigning is design-time only, no calling technique changes that; reconfigure at design time instead.
- Look for the run-time equivalent. Many objects expose a method or a different property for the run-time version of the same job: assigning a record source by name, connecting through a Connect property, or calling an initialization method that takes the object as a parameter.
' Design-time-only assignment (raises 382 at run time):
' Set ctl.DataSource = rs
' Run-time pattern for many data controls instead:
' ctl.RecordSource = "Orders" : ctl.Refresh
- In your own classes, decide Friend versus Public deliberately. If a class you author must accept an object assignment at run time, it needs a Public Property Set. A missing or restricted Property Set in your own code presents exactly this way to your callers.
Error 382 is not a permissions or security restriction. It is the object's own contract about when a property may be set. Running as administrator, or from a different document, changes nothing.
If it still happens
If the property is documented as run-time settable and error 382 persists, verify the object is the class you think it is: a variable typed as a generic Object that actually holds a different, design-time-oriented class will enforce that class's rules. Inspect the object's TypeName at the failure point.
Common questions
What does “at run time” exclude? It means while the program is executing, as opposed to design time, when a developer configures objects in the editor. Some properties exist only for the design-time phase.
How is error 382 different from error 383? Error 383 is about a read-only property: it can be read but never set with an object reference. Error 382 is about timing: the Property Set exists as a concept but cannot execute while the program runs.
Related errors