Create New Record

gray

Registered User.
Local time
Today, 17:03
Joined
Mar 19, 2007
Messages
578
Hi

I want my users to use a custom 'New Record' button. Consequently, I have allowadditions set to false on the form. Note that my form is opened in it's own workspace so that SQL transactions can be used

My custom button calls

Frm_WrkDAO.BeginTrans
DoCmd.GoToRecord , , acNewRec
Me![Edit_Status] = "!!New"

but the "!!!New" gets written into the first record in the recordset... not the new record? I guess there is some way to move to the bookmark of the record before updating the edit-status field?

Incidentally, because the BeginTrans has started, I can't use the
rs.addnew
rs![Edit_Status]="!!!New"
rs.update

method because the BeginTrans will not allow a requery of the form.

And I can't temporarily se tallowadditions to true cos' I only want them to create one record at a time.

Any advice please?
 
Hi

I tried setting the focus to a control but Access still does not scroll to the new record entry row on the form...i.e. the one with (New) in the status column? Code as below

Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
me.First_Name_TextBox.Setfocus

All this does is move to the First_Name_TextBox on the first record... not to the new record row.

How can I position the user to the blank record entry row please?
 
Try using the wizard to add a Command button that adds a new record. (Design View)

From there adapt the code for your purposes.
 
Hi

Thanks for the reply. The Access 2007 button-wizard creates a button with an embedded macro:-.

OnError Next,
GoToRecord ,,New,
[MacroError]<>0 MsgBox =[MacroError].[Description], Yes, None,

If I try to use the button, I get the "Can't go to the specified record" comment... all the 'Allows' are set to true, incidentally.

GoToRecord in VBA needs 'acNewRec'. Sadly, this is what I already have and it does not move to the new record?

thnx
 
Ah... sussed it...

In main-form button_click event, set focus to the required subform then call
RunCommand acCmdRecordsGoToNew

Seems to work fine! So many ways to skin a cat! :)

thnx
 
Hi

Thanks for the reply. The Access 2007 button-wizard creates a button with an embedded macro:-.

OnError Next,
GoToRecord ,,New,
[MacroError]<>0 MsgBox =[MacroError].[Description], Yes, None,

If I try to use the button, I get the "Can't go to the specified record" comment... all the 'Allows' are set to true, incidentally.

GoToRecord in VBA needs 'acNewRec'. Sadly, this is what I already have and it does not move to the new record?

thnx
I didn't realise 2007 created a Macro rather than VBA.

Another thing not to like about 2007
 

Users who are viewing this thread

Back
Top Bottom