473,473 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VBA code to open MS Access form to new, blank record

2 New Member
I saw this question elsewhere on this site, but it was five years old, so I'm asking anew . . .

I want to open a form in Access 2007 (on WinXP) by clicking a button on a different form, and I want the form to open with blank fields, to create a new record in the underlying table.

My code is as suggested in the five-year-old posting, but it doesn't work:

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSetNewGroup_Click()
  2.   DoCmd.OpenForm "frmGroupBasics", , , , acFormAdd
  3. End Sub
What happens is that the form opens to the first record in the table, with the first field highlighted.

Any ideas what's lacking?
Nov 18 '11 #1
3 19196
neelsfer
547 Contributor
try this in On load
Expand|Select|Wrap|Line Numbers
  1.  DoCmd.GoToRecord , "", acNewRec
Nov 18 '11 #2
NeoPa
32,556 Recognized Expert Moderator MVP
The only thing I can think might be happening (as using acNewRec is similar to what you've already tried with acFormAdd) is that the design of the form might be set not to allow these options. You should check the property = AllowAdditions.
Nov 18 '11 #3
Will M
2 New Member
Thanks! I was thinking I needed to specify the new, blank record from the calling control -- didn't think of putting it in the form being opened.
Nov 22 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John | last post by:
I have an Access 2000 form that has a Hyperlink that opens an Excel 2000 worksheet located in the same network folder as the Access MDB. The Hyperlink works great. When users close the Excel...
1
by: Jimmy | last post by:
There is a command button on the form I'm working on. The form displays one record. The command button creates a new record by copying selected data from the current record: Dim dbs As Database...
4
by: Steven | last post by:
Hi, Would need some thought about using a button of the existing form to search record before deleting it. Any quick help is very appreciated. Steve
1
by: Vayse | last post by:
Using Vb 2005 and Access 2000. From within VB, I'd like to open a form in Access. frmCustomer is the form, and I'd like to view the form for a particular CustomerID. I remember doing something...
2
by: Bob Sanderson | last post by:
I want to select a Job Number and Revision from a combo box (cboSelectBOM). I then want to open a form (frmBoM) and display the record for that Job Number and Revision When I double-click on the...
2
by: harley.mcnerthney | last post by:
I have an Access 2007 problem and I would just like to know if there is some sort of solution out there. The problem is, when I build a report that will 99% of the time be one page or less maybe...
6
by: LODIE | last post by:
I have tried to search the forum but kept getting blank page so I apologise if this has already been posted somewhere. I am a GIS officer and we use a mapping software called Exponare Public which...
7
by: chrismaliszewski | last post by:
Hi. I created code which makes dynamically form with bounded controls for all columns. I show it to you below. My problem is, how I have to change this code to create form which record source...
3
by: Barry Putt | last post by:
Hello, I'm trying to find code to use in order to prohibit users from entering spaces into a field on a form in MS Access 07? Any suggestions? Thanks. Barry
3
by: hannoudw | last post by:
Hi i searched here but i didn't find out how to add a button and when i click on this button to open a new blank record? I could really need some help. many thanks :)
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.