Clearing Text Boxes of a Form with a Combo Box

R

Ron

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
 
M

missinglinq via AccessMonster.com

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.
 
J

John Vinson

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]
 
M

missinglinq via AccessMonster.com

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.
 
R

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?

Ron
 
J

John Vinson

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]
 
Top