Hiding New Record until user clicks "Add New Record"

jobrien4

Registered User.
Local time
Today, 13:15
Joined
Sep 12, 2011
Messages
51
I have frm_Parts with a button on it that launches frm_Bevel. frm_Bevel is the form I want to hide the New Record row, and it is a multiple items form that has a tabular layout.

So the OnCurrent for frm_Bevel info has the following code:
Me.AllowAdditions = False

I also have an AddButton where the OnClick:
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec

The new record is hidden when the form loads, but when I hit the Add New button, nothing happens. The add button was working fine before I tried to hide the New Record. Any ideas?
 
Why are you disabling AllowAdditions in the Current event? Have you thought about doing it in the After Insert event of the form? This is by the way anyway.

To your problem. Put a msgbox in the click event just to test that the code fires. Also change the DoCmd to DoCmd.RunCommand acCmdRecordsGoToNew
 
Check the following properties and their settings...

Data Entry = Yes
Allow Deletions = Yes
 
Why am I better off using AfterInsert versus Current? (like I said I have used VBA in 8 years)

I tried this:

Forms("frm_BevelInfo").AllowAdditions = True
Forms("frm_BevelInfo").DataEntry = True
DoCmd.RunCommand acCmdRecordsGoToNew

And I get the following error:

Run-time error '2046':
The command or action 'RecordsGoToNew' isn't available now.
 
From the DoCmd.OpenForm, I added the Forms("frm_BevelInfo").AllowAdditions = False

Then on the click button, I did:

Forms("frm_BevelInfo").AllowAdditions = True
DoCmd.RunCommand acCmdRecordsGoToNew
Forms("frm_BevelInfo").AllowAdditions = False

I'm not sure why that didn't work in the OnCurrent event, but whatever.
 

Users who are viewing this thread

Back
Top Bottom