acNewRec and permissions

R

RipperT

All,

I am using

DoCmd.GoToRecord , , acNewRec

in the load event of a form and it errors out if the form is opened by a
user without permissions to add records. I would like the form to open to a
new record if opened by a user with add permissions, but open to the last
record when opened by a user with only read permissions. How can I do this?

Many thanx,

Rip
 
A

Allen Browne

Add error handling to your routine. If it fails for any reason (e.g. due to
permissions, or a read-only source, or AllowAdditions set to No), call the
code to move to the last record instead like this:
Private Function GoLast()
If Me.RecordsetClone.RecordCount > 0 Then
RunCommand acCmdRecordsGotoLast
End If
End Function

If error handling is new, see:
Error Handling in VBA
at:
http://allenbrowne.com/ser-23a.html
 
G

Guest

Works like a charm. Many thanx.

Ripper

Allen Browne said:
Add error handling to your routine. If it fails for any reason (e.g. due to
permissions, or a read-only source, or AllowAdditions set to No), call the
code to move to the last record instead like this:
Private Function GoLast()
If Me.RecordsetClone.RecordCount > 0 Then
RunCommand acCmdRecordsGotoLast
End If
End Function

If error handling is new, see:
Error Handling in VBA
at:
http://allenbrowne.com/ser-23a.html
 

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