Need to clear controls of Filter form

J

Jan Il

Hi all - Access 2002 XP, W2K :)

I have a small question regarding clearing controls on a form.

How, or where, can I add a bit of code, perhaps on a Filter form, or Record
form, to make sure all the combo boxes and text boxes on the Filter form are
automatically cleared of the previous entries and ready for the next one?

I have tried to put this in the On Open event of the Filter form, so that
when the form is opened again upon returning from the Record form, it will
open the Filter form with no lingering entries in any of the boxes. I have
also tried it in the Filter form Events as well, however, when the Filter
form is opened upon return from the Record form all previous entries are
still in the boxes. I have several types of methods and codes in similar
forms and they work fine, but, for some reason, none want to work in this
form.

One method I have is Me![Combo94] = Null in the Command button code for
each control. Another method I've used before is in the Forms On Activate
event:

Private Sub Form_Activate()

Me![Text0] = Null
Me![Text9] = Null
Me![Combo99] = Null
Me![Combo121] = Null
Me![Text109] = Null

End Sub


However, if I close the current Filter form with the Exit button (a text box
on the Filter form with a Macro to Close the Filter form and Open the main
form, and then reopen the Filter form from the main form the boxes are all
clear. But, not when I go from the Filter form to the Record form and back
to the Filter form. I also now have the Default for the boxes all set to
Null, but, they are still coming back with the entries.

The method that I use to return from the Record form is also an Exit
button/tab, which is a text box with a Macro that Closes the Record form and
Opens the Filter form. I don't fully understand why the entries will clear
when exiting from the Filter form to the main form, or upon opening from the
main form, and yet, will not clear going to or from the Record form, with
all using the Exit button navigation.

I'd really appreciate any suggestions as to which method might work best in
which form or control. I'm totally out of ideas at this point, as what has
worked before is not working now.


Jan :)
Smiles are meant to be shared,
that's why they're so contagious.
 
J

Jan Il

The problem has been resolved using the following method:

Private Sub Form_Activate()
Me.cmbDBTExpense.Value = ""
Me.cmbCheckNo.Value = ""
Me.cmbExpense.Value = ""
Me.cmbPaidTo.Value = ""
Me.TxtDate1.Value = ""
Me.TxtDate2.Value = ""

End Sub

Jan :)
Smiles are meant to be shared,
that's why they're so contagious.
 
J

Jeff Boyce

You may already be aware that a zero-length string (your "") and a Null
(nothing, no value) are not the same. For instance, if you insert zls ("")
into your txtDate2, then subsequently someone looks for rows where txtDate2
is Null, you won't find it!

--
Good luck

Jeff Boyce
<Access MVP>

Jan Il said:
The problem has been resolved using the following method:

Private Sub Form_Activate()
Me.cmbDBTExpense.Value = ""
Me.cmbCheckNo.Value = ""
Me.cmbExpense.Value = ""
Me.cmbPaidTo.Value = ""
Me.TxtDate1.Value = ""
Me.TxtDate2.Value = ""

End Sub

Jan :)
Smiles are meant to be shared,
that's why they're so contagious.



Jan Il said:
Hi all - Access 2002 XP, W2K :)

I have a small question regarding clearing controls on a form.

How, or where, can I add a bit of code, perhaps on a Filter form, or Record
form, to make sure all the combo boxes and text boxes on the Filter form are
automatically cleared of the previous entries and ready for the next one?

I have tried to put this in the On Open event of the Filter form, so that
when the form is opened again upon returning from the Record form, it will
open the Filter form with no lingering entries in any of the boxes. I have
also tried it in the Filter form Events as well, however, when the Filter
form is opened upon return from the Record form all previous entries are
still in the boxes. I have several types of methods and codes in similar
forms and they work fine, but, for some reason, none want to work in this
form.

One method I have is Me![Combo94] = Null in the Command button code for
each control. Another method I've used before is in the Forms On Activate
event:

Private Sub Form_Activate()

Me![Text0] = Null
Me![Text9] = Null
Me![Combo99] = Null
Me![Combo121] = Null
Me![Text109] = Null

End Sub


However, if I close the current Filter form with the Exit button (a text box
on the Filter form with a Macro to Close the Filter form and Open the main
form, and then reopen the Filter form from the main form the boxes are all
clear. But, not when I go from the Filter form to the Record form and back
to the Filter form. I also now have the Default for the boxes all set to
Null, but, they are still coming back with the entries.

The method that I use to return from the Record form is also an Exit
button/tab, which is a text box with a Macro that Closes the Record form and
Opens the Filter form. I don't fully understand why the entries will clear
when exiting from the Filter form to the main form, or upon opening from the
main form, and yet, will not clear going to or from the Record form, with
all using the Exit button navigation.

I'd really appreciate any suggestions as to which method might work best in
which form or control. I'm totally out of ideas at this point, as what has
worked before is not working now.


Jan :)
Smiles are meant to be shared,
that's why they're so contagious.
 

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