Full Version: Adding new record with allow additions set to no
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
loneblade
Is there anyway to set a continuous form's allow additions property to No, yet insert a new record through vba?

I get a runtime error 2105, "you can't go to the specified record", with my current code.

Thanks
rsindle
You can always generate the record in code, append it via SQL, then requery the form.

Or, if you want them to be able to add a row manually. Put a button that will enable the New record.

Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec

THen in the AfterUpdate event of the form, turn off the AllowAdditions property:

Me.AllowAdditions = False

Rob
ace
Well you won't be able to go to an empty row to add values
if AllowAdditions is set to no so I you'll have to explain where
you want to enter values for the new record.

Popping up an entry form is a reasonable thing to do.
rsindle
Either of these 3 will work.
1. Compute in code and insert via SQL and requery the form (my example1)
2. Enable allowAdditions, edit, turn it off (my example2) (for manual input)
3. Open a data entry form (Ace's example). (for manual input)

HTH,
Rob
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.