Trying to clear combo boxes' Text property..

  • Thread starter Thread starter every1luvsVB
  • Start date Start date
E

every1luvsVB

Hello fellow VB programmers, am at a loss with this one..

I have a 2-toggle button frame on a form. The point of the toggling is to
hide / make visible certain combo boxes on this form, depending one which
toggle is pressed, and vice versa, for the other toggle.

On frame update event, I call a custom function that 'initialises' the form,
i.e. sets certain controls' visibility properties and (most particularly for
this issue..) clears the combo boxes' text properties (so that the next time
certain combo boxes appear, they will not be displaying their previously
selected values..) My function basically comprises of a case statement, based
on either numeric toggle value..

HOWEVER, when code execution reaches the clearing of the combo boxes' text
property, i.e.

thisForm!cboMember.SetFocus
thisForm!cboMember.Text = ""

-I run into grief, on the attempted NULL assignment, i.e. I receive the
following error message:

'The macro or function set to the BeforeUpdate or ValidationRule property for
this field is preventing [db_name] from saving the data in the field.' OK

Well it isn't OK -cos there aint no BeforeUpdate or ValidationRule code that
I can see. Although this error seems to commonly appear in various discussion
threads, I can't find a relevant solution for the damned thing!!

Any help would be appreciated. Thanks heaps!
 
I would try the following

One, don't bother moving to the combobox.
Two, use the combobox value property
Three, set it to NULL versus a zero-length string.

ThisForm!CboMember= Null

My guess is that the combobox is bound and the field doesn't allow
zero-length strings.
 
every1luvsVB said:
Hello fellow VB programmers, am at a loss with this one..

I have a 2-toggle button frame on a form. The point of the toggling
is to hide / make visible certain combo boxes on this form, depending
one which toggle is pressed, and vice versa, for the other toggle.

On frame update event, I call a custom function that 'initialises'
the form, i.e. sets certain controls' visibility properties and (most
particularly for this issue..) clears the combo boxes' text
properties (so that the next time certain combo boxes appear, they
will not be displaying their previously selected values..) My
function basically comprises of a case statement, based on either
numeric toggle value..

In VB you normally use the Text property for stuff like this. In Access VBA you
use the Value property. Access controls have a Text property but it is
different than it is in VB. In Access the Text property is the typed entry in a
control before the value is updated. It is only accessible when the control has
focus.

Since Value is the default property of controls you don;t need to explicitly
reference it. Just eliminate the Got focus line and then use...

thisForm!cboMember = Null
 
Rick said:
Hello fellow VB programmers, am at a loss with this one..
[quoted text clipped - 9 lines]
function basically comprises of a case statement, based on either
numeric toggle value..

In VB you normally use the Text property for stuff like this. In Access VBA you
use the Value property. Access controls have a Text property but it is
different than it is in VB. In Access the Text property is the typed entry in a
control before the value is updated. It is only accessible when the control has
focus.

Since Value is the default property of controls you don;t need to explicitly
reference it. Just eliminate the Got focus line and then use...

thisForm!cboMember = Null

John, Rick,

thankyou both for your help.. Your solution worked a treat!

For the benefit of other readers:

* I removed the setFocus line
* referred to thisForm!cboMember.Text as thisForm!cboMember
* and instead of assigning a zero-length string, i.e. "", I assigned the
value of Null.

Cheers guys.
 

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

Back
Top