Clearing Text Boxes of a Form with a Combo Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am sure this is a simple task, but I just can't seem to make it work. I
have a form, upon which I have a combo box that is unbound. The pull-down
works perfectly and populates the fields with the record selected. My
problen is that I want the form to open with all the fields blank. Currently
the combo box comes up blank, but all the others come up with the data of the
first record. Any assistance you can provide would be greatly appreciated.

Ron
 
In the Form's Properties Box goto Data, then set Data Entry to Yes. The Form
will open with a new record, ready to go.
I am sure this is a simple task, but I just can't seem to make it work. I
have a form, upon which I have a combo box that is unbound. The pull-down
works perfectly and populates the fields with the record selected. My
problen is that I want the form to open with all the fields blank. Currently
the combo box comes up blank, but all the others come up with the data of the
first record. Any assistance you can provide would be greatly appreciated.

Ron

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
I am sure this is a simple task, but I just can't seem to make it work. I
have a form, upon which I have a combo box that is unbound. The pull-down
works perfectly and populates the fields with the record selected. My
problen is that I want the form to open with all the fields blank. Currently
the combo box comes up blank, but all the others come up with the data of the
first record. Any assistance you can provide would be greatly appreciated.

Ron

Put a single line in the form's Open event:

Private Sub Form_Open(Cancel as Integer)
DoCmd.GoToRecord acForm, Me.Name, acNewRec
End Sub

I may be misremembering the new record constant, it'll be in the
autosense though.

Setting the form's Data Entry property might work, but that's designed
to prevent viewing existing records and may intefere with your
navigation combo box.

John W. Vinson[MVP]
 
John's correct, if you want your user to be able to navigate to other records
after entering a new record Data Entry = Yes won't allow that, and

Private Sub Form_Open(Cancel as Integer)
DoCmd.GoToRecord , , acNewRec
End Sub

will allow that. If you ONLY want your user to enter a new record, then my
previous answer is the way to go.
 
I use the combo box to select a record to be edited, so setting the form for
Data Entry causes the combo box to not work. I am able to select a record,
but it does not go to that record. With Data Entry set to "No", it operates
as expected. I put the code provided below, but it does not cause the form
to open with empty text boxes. I will recheck my code, though. Any other
thoughts?

Ron
 
I use the combo box to select a record to be edited, so setting the form for
Data Entry causes the combo box to not work. I am able to select a record,
but it does not go to that record. With Data Entry set to "No", it operates
as expected. I put the code provided below, but it does not cause the form
to open with empty text boxes. I will recheck my code, though. Any other
thoughts?

my brainfade - make it the form's Load event, not its Open event.

John W. Vinson[MVP]
 
I finally took a non-VBA approach and noticed that the form always opened
with the data of the first record. I replaced the first record with a blank
record and the problem is solved. Not a very technical approach, but it
works fine. I did not mention in my original question that the text boxes I
wanted cleared are bound text boxes, so I am assuming that is why the code
that was suggested didn't work. Thanks for all of your suggestions.

Ron
 

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