Newbie Question: How can I start my form at a blank new record?

  • Thread starter Thread starter michaaal
  • Start date Start date
M

michaaal

Whenever I make a form in Access and double-click on it the default record
is the first one in the database. How can I make the default record to be
the new "blank" one that is going to be entered?

Sorry for the Newbie Question.

thanks!!
 
You could create a command button on a unbound form (a form which isn´t
linked to any row source (table & query)). On this unbound form create a
command button and type in following VBA code in the command buttons click
event:

DoCmd.OpenForm "frmYourFormsName", acNormal, , , acFormAdd

acFormAdd = add a new record. So this is what you are after!

This will cause the fom to open up with a new record in which the user can
add new data.

I small tip is to open up the code window <Tool / Macro / Visual Basic
Editor (or Alt + F11) and type in "DoCmd.OpenForm".

Set cursor in "OpenForm" and press F1. This will open up the helpfile for
"OpenForm" and you can read about it!

// Niklas
 
Niklas Östergren said:
You could create a command button on a unbound form (a form which isn´t
linked to any row source (table & query)). On this unbound form create a
command button and type in following VBA code in the command buttons click
event:

Wow...I hear ya. You would think there would be an easier way to do this!!
 
Niklas Östergren said:
You could create a command button on a unbound form (a form which isn´t
linked to any row source (table & query)). On this unbound form create a
command button and type in following VBA code in the command buttons click
event:

DoCmd.OpenForm "frmYourFormsName", acNormal, , , acFormAdd

Niklas, thanks again for the info! I just wanted to share with you and
everyone the way I accomplished this. I put your advised code in the "Form
/ Load" section of my form and it worked great!!
 
If you want to dedicate a form to data entry, you can do so by selecting
that option in the form's properties.

You might find www.mvps.org/access a worthwhile site to visit. You might
also find it instructive to see some other Access related newsgroups by
looking them up in the Newsgroups dialogue. There are groups on everything
from microsoft.public.access.activex to
microsoft.public.access.gettingstarted.

HTH
 
If you want the form for data entry only, i.e., the user can not see existing records, as someone else said, just set the form's
Data Entry property to Yes.

If you want all of the records available and just want the form positioned to a new record, then in the form's load event put:

DoCmd.RunCommand acCmdRecordsGoToNew

--

Sco

M.L. "Sco" Scofield, MCSD, MCP, MSS, Access MVP, A+
Useful Metric Conversion #16 of 19: 2 monograms = 1 diagram
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 
Back
Top