problems with adding a new record to a form in a2k

G

Guest

i want to limit users ability to add records on my 'Screening Log' form to a
button i placed in the form header courtesy of the button 'wizard' to create
an 'add record' button. in the form's properties i have disabled the 'allow
additions' property so when i open the form the little '*' is stippled/greyed
out and unavailable to the user. i am using the following code


Private Sub AddRecord_Click()
On Error GoTo Err_AddRecord_Click

Me.AllowAdditions = True ' added by me

DoCmd.GoToRecord , , acNewRec

Me.AllowAdditions = False ' added by me

Exit_AddRecord_Click:
Exit Sub

Err_AddRecord_Click:
MsgBox Err.description
Resume Exit_AddRecord_Click

End Sub

which but for the pair of lines added by yours truly comes straight from the
cmdbtn wizard's mouth. so why doesn't it work: when i click the button the
record counter thing at the bottom of the form goes from 229 to 230 and then
back to 229 again (there are 229 records in the underlying table). what's up
with all this. i thought this would be really not all this difficult, so what
am i doing wrong?

thanks for any suggestions.

-ted
 
G

Guest

ofer,

i'm not really sure i understood your response. i don't have a problem with
the user's using either the mouse wheel to scroll through the records OR the
navigation button to move from one to the next. i just think it'd be better
to have them have to use the 'Add Record' button.
 
G

Guest

Why you not removing the NavigationButtons by seting the NavigationButtons
Property of the form to No.
If all you want to do, is not give the user the ability to add new records
using this option.

If you want to add navigation buttons, then add buttons to the form that you
can use to move between records
 
G

Guest

I tried to understand from your code the reason you are trying to add a
differen button th the form to add a new record, after all the resault will
be the same.

To use the button on the form to add a record and then change the form
property back to No so the user can't add records, you'll need to save the
record after adding it, and then change the status to No.
 
G

Guest

Private Sub AddRecord_Click()

On Error GoTo Err_AddRecord_Click

Me.AllowAdditions = True ' added by me

DoCmd.GoToRecord , , acNewRec
'The line below is your problem. It needs to be moved to the After Insert
event of the form. AllowAdditions needs to be true until the record is added
to the table.

Me.AllowAdditions = False ' added by me

Exit_AddRecord_Click:
Exit Sub

Err_AddRecord_Click:
MsgBox Err.description
Resume Exit_AddRecord_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top