Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blank record at end of form

Status
Not open for further replies.

Fonzie

MIS
Feb 16, 2001
74
CA
I have a basic form setup to enter employee information. There are command buttons on the form to go to the previous or next record. The problem is there is always a blank record displayed as the last record. Is there any way to not show the blank record?
 
I am pretty much a newbie myself but I think that blank form is to add a new record. But if you go into the form properties and change the allow additions property from Yes to No, it should correct the problem you are having. However, keep in mind that this will not allow users to add any new employees.
 
I still need users to add new records, but when they are searching through the existing records, I don't want the last blank record to appear. If they want to add a new record, I have included a 'New Record' button for them.
 
Yo Fonzie, (sorry, I had to do that)...
Set your form as iXPHound has suggested: Allow Additions = No.
Now when your user clicks a command button to go to a new record we'll add this:

Me.AllowAdditions = True

'You Probably have this already ->DoCmd.GoToRecord , , acNewRec

Me.AllowAdditions = False

That's it! Gord
ghubbell@total.net
 
Thanks Gord.

I Tried what you suggested, but it doesn't work for me. This is the exact code I have in the 'On Click' event for the new record button:

Private Sub NewRecord_Click()
On Error GoTo Err_NewRecord_Click
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
Me.AllowAdditions = False

Exit_NewRecord_Click:
Exit Sub

Err_NewRecord_Click:
MsgBox Err.Description
Resume Exit_NewRecord_Click

End Sub

Is this what you suggested, or am I doing something wrong?
 
Try this:

Private Sub NewRecord_Click()
On Error GoTo Err_NewRecord_Click
DoCmd.RunCommand acCmdSaveRecord
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
DoCmd.RunCommand acCmdSaveRecord
Me.AllowAdditions = False

Exit_NewRecord_Click:
Exit Sub

Err_NewRecord_Click:
MsgBox Err.Description
Resume Exit_NewRecord_Click
End Sub

What we're doing is saving the current record, then allowing the form to accept a new record, then travelling to a new record, then saving that new record, then removing the ability to add another new record. There are issues here so if you don't have all of your "required" fields with default values set, it will get upset at trying to save the "incomplete" new record. That's the only thing I see that could cause you grief. If this is the case, remove the last two lines and place them in the "after update" event of the last field you consider "required". (This is not a really "sano" idea as a user could again click "New Record" in the midst of entering the first.) Play with this a bit and if it's still not right we'll do a bit of button "disabling"...

Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top