Clearing fields on a form (on open) when a combo box is used

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

Guest

I have carfully read all of the questions regarding combo boxes and cannot
find anything that applies. I know it's simple, but I just can't seem to get
it. I have a form with an unbound combo box which is used to select a
record. That works fine. What I want is for the form to open with all of
the fields blank. Any guidance you can provide would be greatly appreciated.

Ron
 
Ron said:
I have carfully read all of the questions regarding combo boxes and
cannot find anything that applies. I know it's simple, but I just
can't seem to get it. I have a form with an unbound combo box which
is used to select a record. That works fine. What I want is for the
form to open with all of the fields blank. Any guidance you can
provide would be greatly appreciated.

Ron

Assuming that this is a bound form then the only time the controls will all be
blank is when you are on the new record position. You would have to use code in
the Open event to take the form to that position.

DoCmd.RunCommand acCmdRecordsGoToNew
 
Rick,

Thanks for the quick answer. Since I am not a VBA guru, I will need a
little more information as to exactly what code to include and on that
action. I tried just adding it to the control to open the form, but it
bombed. Thanks in advance for your help.

Ron
 
Ron said:
Rick,

Thanks for the quick answer. Since I am not a VBA guru, I will need a
little more information as to exactly what code to include and on that
action. I tried just adding it to the control to open the form, but
it bombed. Thanks in advance for your help.

In the property sheet of the form while in design view go to the Events tab and
find the On Open event property. In the list of choices choose [Event
Procedure] then press the build button [...] to the right. In the VBA window
that will open enter...

DoCmd.RunCommand acCmdRecordsGoToNew

....between the two lines that will have been pre-built that define the
sub-routine for the Open event.
 
Rick,

Adding this code to the command used to open the form accomplished the task
and resolved my issue:

DoCmd.GoToRecord , , acNewRec

Thanks for your help. Without it I would have never solved my problem.

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