In pure VB, where the Text property of a control is the default property, so
VB people often get confused about this when they come to Access. In Access,
you usually want to refer to the Value of a control rather than its Text
property. Text applies only to the edits in process in a control that has
focus.
If the form does not allow additions, and has no records, the Detail section
goes completely blank. No control has focus, so you cannot use the Text
property. In fact, the controls don't exist in the Detail section, and so
you cannot refer to their Value property either. To avoid the error, you
would need to explicitly test for reccords first, e.g.:
If Me.RecordsetClo ne.RecordCount > 0 Then
If Me.MyControl.Va lue = 999 Then ...
If the form has no records and new records cannot be added, but your control
is in the Form Header or Form Footer section, you can see the control, and
it can take focus, so you would expect to be able to refer to its Value or
Text property. But if you attempt it, there are known bugs in all versions
of Access that give unreliable results. For a description and sample, see:
Incorrect display of data
at:
http://allenbrowne.com/bug-06.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"BUX" <pi***@pippo.it > wrote in message
news:2f******** *************** *********@4ax.c om...
If I try to read MyControl.text I receive Run-Time error 2185 that
means about < Impossible to refer to a property or a metod if the
control is not active >.
But this happen only if the form have no record and ALLOWADDITION is
set to FALSE.
Do you know in this case how can I get MyControl.text ?
thank you