Can't assign value

M

Mike Collard

I have form with several text boxes that are populated by
a procedure triggered by the On Open event of the form.

I want to create a Cancel button to undo any unsaved
changes so I have copied the following code from the
Access Help file but get 'error 2448. Can't assign value
to this object.'

Sub btnUndo_Click()

Dim ctlC As Control
' For each control.
For Each ctlC In Me.Controls
If ctlC.ControlType = acTextBox Then
' Restore Old Value.
ctlC.Value = ctlC.OldValue
End If
Next ctlC

End Sub

Any ideas?

Thanks
 
T

tom

Mike,

The "OldValue" property only applies to bound controls, and it
sounds like you are using unbound controls on this form.

Instead, how about running the code that loads values into your form
when they press Cancel, that way they are in the same position as when
they started?

-td
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top