How to Make Control Value to Null (Leo asked)

G

Guest

Hi there,
Based on my main-form controls values, my sub-form shows the query result.
Now if Control1.value has certain values, then Control2.value must be left
Null on the main form, otherwise the query results in no record in sub-form.
Now the question is how I can turn a control's value to Null (without user's
manual input)?? Is there anyway at all??
I know that these are impossible;
Control2.Value = Null ' I can not assign Null value to variables
Control2.Value ="" ' it makes a zero lenght string (Not Null) which implies
for the
'query that something is there
Please help!
 
B

Baz

Whether you can assign Null to a variable depends on the data type of the
variable. It works for Variants.

In any case, Control2 isn't a variable, it's a control. Assigning Null to
the value of a control has always seemed to work OK for me.
 
G

Guest

A control is not a variable.
Only a Variant variable can receive a Null.
Controls can receive a Null value.

Do not use the Value property. It is not necessary. I don't know since I
never use the value property, but it may be possible that is the problem.
Just use:
Me.Control1 = Null
or
Forms!FormName!Control1
if the control is not in the same form as the code.

It is also possible, since you are not using the form reference that Access
is getting confused about what Control1 is. Maybe it thinks it is a variable.
 

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