Home > Microsoft Access Help > Can't assign value

Can't assign value



I have form with several text boxes that are populated by a procedure called from a combo box from which the user makes a selection.



I want to create a Cancel button to undo any unsaved changes to the text boxes 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?

    
Guest


You try to set "Value". Try to set .Text instead. Also do not try to set values in calculated fields. They will refuse that with a similar error message.

When you have calculated fields and others that store values in the database it may be better to use a particular name prefix in order to distinguish them (dbf = db field). acTextBox will not be sufficient as a criterion and you would then use:



If Left(ctlC.name, 3) = "dbf" Then

Was this answer helpful ? Yes No   
Guest


Thanks

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved