Form / Button to Add New Record...

GUIDO22

Registered User.
Local time
Today, 16:12
Joined
Nov 2, 2003
Messages
515
I am using a table to hold data relating to 3 very similar products, one distinction is that one of these items has a value in that remains constant. If I set this field to have a default value at table design level - all 3 units get this same value, which is incorrect.

I am using continuous forms and if I use VBA code in the Current() event I can prefil the coresponding text field with the default value .... but, it is quite easy to add additional rows without meaning to, the problem here is that if the user creates records in error selection of the record pointer will not permit its removal from within the form - even through AllowDeletions is enabled.

So, if I disable AllowAdditions in the form properties - the form now prevents any new rows being added to the form at all... which is what I expect.
However, I was hoping to add a command button to othe form footer for the user to physically confirm before the record is added to the form but I dont know what function to call to add the new record to the form....

Im sure this is a simple one for one or two of you out there....? Thanks...
 
Just solved it... in the button event - Prompt the user to confirm the addition of the new record - temporarily change the forms AllowAdditions property to TRUE , add the new record, then change the property back again..!

nVar = QuestionMessage("Add New Record?", "New Record Prompt")

If (nVar = vbYes) Then
Me.Form.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
Me.Form.AllowAdditions = False
End If
 

Users who are viewing this thread

Back
Top Bottom