Need to eliminate generic new record and use "Add Rec" button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an "Add Record" button which was made with the wizard, so it's correct
It generates "you can't go to specified record" when I push it
When I changed the form's properties "Allow Additions" to "Yes", "Add Rec" works--but I also get a generic new record with an "*" at the bottom of the list. If the user fills in the "*" record, "Add Rec" record, an important data field is not set. How can I have the button work without having the "*" blank record?
 
Desert Bear said:
I have an "Add Record" button which was made with the wizard, so it's
correct.
It generates "you can't go to specified record" when I push it.
When I changed the form's properties "Allow Additions" to "Yes", "Add
Rec" works--but I also get a generic new record with an "*" at the
bottom of the list. If the user fills in the "*" record, "Add Rec"
record, an important data field is not set. How can I have the button
work without having the "*" blank record?

You can have the button first set the form's AllowAdditions property to
True before going to the new record, and then set that property back to
False in the form's AfterInsert event. Here are example event
procedures from a form that takes a similar, but slightly different
approach -- when the "cmdAddRecord" button is clicked, it sets the
form's DataEntry property to True, so that the user sees only the new
record. You may or may not want to copy this approach, but here's the
example code:

'----- start of example code -----
Private Sub cmdAddRecord_Click()

Me.AllowAdditions = True
Me.DataEntry = True

End Sub

Private Sub cmdCancelAdd_Click()

Me.Undo
Me.DataEntry = False
Me.AllowAdditions = False
Me.AllowEdits = True
Me.AllowDeletions = True

End Sub

Private Sub Form_AfterInsert()

Me.DataEntry = False
Me.AllowAdditions = False
Me.AllowEdits = True
Me.AllowDeletions = True

End Sub
'----- end of example code -----
 
Turn Allow Additions off. Put the following code in the click event of your Add
Record button:

Me.AllowAdditions = True
DoCmd.GotoRecord,,acNewrec


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


Desert Bear said:
I have an "Add Record" button which was made with the wizard, so it's correct.
It generates "you can't go to specified record" when I push it.
When I changed the form's properties "Allow Additions" to "Yes", "Add Rec"
works--but I also get a generic new record with an "*" at the bottom of the
list. If the user fills in the "*" record, "Add Rec" record, an important data
field is not set. How can I have the button work without having the "*" blank
record?
 
Back
Top