Uncheck box & clear combo box in new records

P

Pickymiss

I see that this has been answered in a few different ways before, but I can't
figure out how to apply those solutions in my case.

Data from the previous record "visually lingering" in the new record is
confusing to the users who are inputting data. The data is not in the table
for the new record; it is just sitting in the box, so it looks like it is
already full. I have check boxes to clear. I also have combo boxes that are
picking from a table with a list of choices.

The post from 11/6/2008 by Serendipity has a solution of adding code to
clear the textboxes -- ME.TextBox1 = " " and also -- ME.Checkbox1 = 0. I
don't know what those refer to. What is "ME" and do "TextBox" and "Checkbox"
refer to form objects, or table fields?

How can I use the solution Dennis gave to Serendipity? (See: New Record
Command Button") Is that code something that I apply to a command button,
naming each table/field to clear out, or do I put it into the properties of
each of the form's fields in the Event tab? Do I have to use VBA and if so,
how do I find the right way to do that? Does it have to be through a command
button that I create, or would the "new record" button do it?

I have been struggling to do this and then setting it aside due to
frustration. I'm extremely inexperienced with VBA, so if someone could walk
me through it I would appreciate it. Any assistance would be fantastic.
 
J

Jeanette Cunningham

Hi Pickymiss,
assuming the combo is unbound, you can clear it like this

Me.[NameOfCombo] = Null

Me - refers to the form where the code is running, the form with the combo.
[NameOfCombo] is the name of the combo, look on its property dialog on the
other tab to get its name.

So on your form if you have an unbound combo that is called
cboFilterMainName
To clear it you would code
Me.cboFilterMainName = Null

A checkbox can be ticked, checked or it can be not ticked, unchecked.
To make a checkbox unchecked you set it to False.

For a checkbox called Active, to clear it you code
Me.Active = False

The problem of data 'lingering' is the way that unbound controls behave when
you move to a new record on the same form.
If you close and then open the form, the unbound controls are cleared
automatically.

You can put the code on the Current event for the form something like this

If Me.NewRecord = True Then
Me.[NameOfCombo] = Null
Me.[NameOfCheckbox] = False
End If


When the form goes to a new record, access automatically has a look to see
what code is in the Current event.
Access runs any code in the Current event when the form goes to a new
record.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
P

Pickymiss

Jeanette... Thank you so much for this reply.

I am pretty sure (again, knowledge gap) that the combo box is bound. It
does link to a table with the possible choices and also is used to input the
data for a field in another table. Can I change it to being unbound without
disabling its ability to do its job?

I do see the light at the end of the tunnel now and I am feeling much better
about solving this! Please let me know about the bound/unbound if you can.

Thank you!

Jeanette Cunningham said:
Hi Pickymiss,
assuming the combo is unbound, you can clear it like this

Me.[NameOfCombo] = Null

Me - refers to the form where the code is running, the form with the combo.
[NameOfCombo] is the name of the combo, look on its property dialog on the
other tab to get its name.

So on your form if you have an unbound combo that is called
cboFilterMainName
To clear it you would code
Me.cboFilterMainName = Null

A checkbox can be ticked, checked or it can be not ticked, unchecked.
To make a checkbox unchecked you set it to False.

For a checkbox called Active, to clear it you code
Me.Active = False

The problem of data 'lingering' is the way that unbound controls behave when
you move to a new record on the same form.
If you close and then open the form, the unbound controls are cleared
automatically.

You can put the code on the Current event for the form something like this

If Me.NewRecord = True Then
Me.[NameOfCombo] = Null
Me.[NameOfCheckbox] = False
End If


When the form goes to a new record, access automatically has a look to see
what code is in the Current event.
Access runs any code in the Current event when the form goes to a new
record.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Pickymiss said:
I see that this has been answered in a few different ways before, but I
can't
figure out how to apply those solutions in my case.

Data from the previous record "visually lingering" in the new record is
confusing to the users who are inputting data. The data is not in the
table
for the new record; it is just sitting in the box, so it looks like it is
already full. I have check boxes to clear. I also have combo boxes that
are
picking from a table with a list of choices.

The post from 11/6/2008 by Serendipity has a solution of adding code to
clear the textboxes -- ME.TextBox1 = " " and also -- ME.Checkbox1 = 0. I
don't know what those refer to. What is "ME" and do "TextBox" and
"Checkbox"
refer to form objects, or table fields?

How can I use the solution Dennis gave to Serendipity? (See: New Record
Command Button") Is that code something that I apply to a command button,
naming each table/field to clear out, or do I put it into the properties
of
each of the form's fields in the Event tab? Do I have to use VBA and if
so,
how do I find the right way to do that? Does it have to be through a
command
button that I create, or would the "new record" button do it?

I have been struggling to do this and then setting it aside due to
frustration. I'm extremely inexperienced with VBA, so if someone could
walk
me through it I would appreciate it. Any assistance would be fantastic.
 
J

Jeanette Cunningham

If I have a bound combo with customer's last name - that means when I choose
a last name, the current record gets the name chosen in the combo.
The problem is that if you set this combo to Null, the record gets null for
the last name, which is not what you intended.

If you have a combo to search for records, it is advisable to make it
unbound.
That means that its control source is empty and it can't write data back to
a table.
However the combo get its data for the drop down list from a table or query
and that is called its row source.

You can have 2 combos on your form - one that let's you choose the customer
or whatever for this record and a separate combo that is unbound and let's
you search for records.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Pickymiss said:
Jeanette... Thank you so much for this reply.

I am pretty sure (again, knowledge gap) that the combo box is bound. It
does link to a table with the possible choices and also is used to input
the
data for a field in another table. Can I change it to being unbound
without
disabling its ability to do its job?

I do see the light at the end of the tunnel now and I am feeling much
better
about solving this! Please let me know about the bound/unbound if you
can.

Thank you!

Jeanette Cunningham said:
Hi Pickymiss,
assuming the combo is unbound, you can clear it like this

Me.[NameOfCombo] = Null

Me - refers to the form where the code is running, the form with the
combo.
[NameOfCombo] is the name of the combo, look on its property dialog on
the
other tab to get its name.

So on your form if you have an unbound combo that is called
cboFilterMainName
To clear it you would code
Me.cboFilterMainName = Null

A checkbox can be ticked, checked or it can be not ticked, unchecked.
To make a checkbox unchecked you set it to False.

For a checkbox called Active, to clear it you code
Me.Active = False

The problem of data 'lingering' is the way that unbound controls behave
when
you move to a new record on the same form.
If you close and then open the form, the unbound controls are cleared
automatically.

You can put the code on the Current event for the form something like
this

If Me.NewRecord = True Then
Me.[NameOfCombo] = Null
Me.[NameOfCheckbox] = False
End If


When the form goes to a new record, access automatically has a look to
see
what code is in the Current event.
Access runs any code in the Current event when the form goes to a new
record.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Pickymiss said:
I see that this has been answered in a few different ways before, but I
can't
figure out how to apply those solutions in my case.

Data from the previous record "visually lingering" in the new record is
confusing to the users who are inputting data. The data is not in the
table
for the new record; it is just sitting in the box, so it looks like it
is
already full. I have check boxes to clear. I also have combo boxes
that
are
picking from a table with a list of choices.

The post from 11/6/2008 by Serendipity has a solution of adding code to
clear the textboxes -- ME.TextBox1 = " " and also -- ME.Checkbox1 = 0.
I
don't know what those refer to. What is "ME" and do "TextBox" and
"Checkbox"
refer to form objects, or table fields?

How can I use the solution Dennis gave to Serendipity? (See: New
Record
Command Button") Is that code something that I apply to a command
button,
naming each table/field to clear out, or do I put it into the
properties
of
each of the form's fields in the Event tab? Do I have to use VBA and
if
so,
how do I find the right way to do that? Does it have to be through a
command
button that I create, or would the "new record" button do it?

I have been struggling to do this and then setting it aside due to
frustration. I'm extremely inexperienced with VBA, so if someone could
walk
me through it I would appreciate it. Any assistance would be
fantastic.
 

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