Senin, 23 Juli 2012

RE: [MS_AccessPros] Add/Delete record on the same form

 

Thomas-

It's OK to set Allow Additions to No, but you have to circumvent that in your
create new record code:

Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec

Then in the AfterUpdate event of the form do this:

Me.AllowAdditions = False

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Thomas
Sent: Monday, July 23, 2012 9:45 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Add/Delete record on the same form

I have a form with data source from a query. I would like to allow the user to
create new record(s) (base on a button on the form header) and to delete
selected records (base on a button next to the record display).

However, if I enable the "Allow additions" attribute on the form, there is
always a 'new record' appears at the end of the form which I don't want it to
appear until the 'Add/Create' button is clicked. If I set the "Allow additions"
to NO, the create new button will not work.

The code for the create new record is
DoCmd.GoToRecord , , acNewRec

and the code for the delete is

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

How do you circumvent this problem? Thanks.

Thomas

------------------------------------

Yahoo! Groups Links

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar