
Update method causes untrappable error.
Well I've found out why I was getting this error - "Text property is
read-only" on updating the database. Ultimately its a bug with VB ...
I had a combobox set to style two which is a non-editable drop down
list.
Since the text property of this style of combobox is read-only any
attempt to modify the text property of the control causes the error.
HERES WHERE THE BUG COME IN ....
Attempts to set the data in the database field associated with the
combobox control can also trigger the error effectively rendering your
program unable to modify the database field without generating an
error! (Using update queries to change the field appear to work
thought but you would have to save the record and update the recordset
first.)
Well when I commented out the code modifying the field in the database
the error STILL popped up!
It appears that the simple act of creating a new record using addnew
is enough to set the stage for this error to pop up after the update
method is finished and all the events triggered by the update event
are finished!!!
The workaround. ....
Blank out the datasource and datafield properties of the combobox.
Create an edit box with the datasource and datafield properties are
set to the values that WERE in the combobox.
Place the edit box over the text area of the combobox leaving the
down-pointing button of the combobox uncovered.
In the CLICK event of the combobox put something like the following
code ...
textboxName.text = comboboxName.text
In the gotfocus event of the edit box put the following code ...
comboboxName.SetFocus
This will prevent the user from editing the contents of the edit box.
The result will look and act just like the intended combobox should
have MINUS the error message because now the field is associated with
the text of a writeable control - The EDIT box will display the text
found in the database field. The code in the GotFocus event of the
text box prevents the user from editing the text property of the edit
box directly and the visible portion of the combobox (The Arrow)
allows the user to select the item desired and when the item is
selected the click event of the combobox updates the editbox text and
the underlying record is saved when the user clicks on save.
Thats it. I'd rather not have to kludge but thats the way I am using
until a better idea comes along.