Command button works for some users but not others

E

Erin

Hi there, i have an entry form with the following code on a command button to
add a new record. This button works for some users but not others, any ideas?
could it be a security setting?

Private Sub cmdAddnew_Click()
On Error GoTo Err_cmdAddnew_Click


DoCmd.GoToRecord , , acNewRec
Me!ProjectID = DMax("[ProjectID]", "[MainTracking]") + 1
Me.Project_Pre2007 = Me.ProjectID
Me.LinkToReport = "E:\Library\Reports\" & [Project#Pre2007] & ".pdf"
Me.DateEntered = Date


Exit_cmdAddnew_Click:
Exit Sub

Err_cmdAddnew_Click:
MsgBox Err.Description
Resume Exit_cmdAddnew_Click

End Sub
 
D

David H

Can the user's for which this particular bit of code doesn't work execute
other code? If its a security issue with their machine, then no code will
execute. Are they getting ANY error message?

I did add some line questions that are more stylistic...

Erin said:
Hi there, i have an entry form with the following code on a command button to
add a new record. This button works for some users but not others, any ideas?
could it be a security setting?

Private Sub cmdAddnew_Click()
On Error GoTo Err_cmdAddnew_Click


DoCmd.GoToRecord , , acNewRec
Me!ProjectID = DMax("[ProjectID]", "[MainTracking]") + 1
Are the project ID's simply numbers that increment by one? If so, have you
looked at changing the field type to Autonumber? Doing so will eliminate the
need to do a DMax() and avoid any conflicts from two users adding a record at
the same time. If you do have to use DMax() you can set the control's default
value to the expression as in =DMax([whatever])
Me.Project_Pre2007 = Me.ProjectID
Me.LinkToReport = "E:\Library\Reports\" & [Project#Pre2007] & ".pdf"
Why is the variable named Project#Pre2007 when the variable above is
Project_Pre2007?
Me.DateEntered = Date
Do you have a control on the form that displays the value in the DataEntered
field? If so, set the DefaultValue to =Date()
 
D

David H

Can the user's for which this particular bit of code doesn't work execute
other code? If its a security issue with their machine, then no code will
execute. Are they getting ANY error message?

I did add some line questions that are more stylistic...

Erin said:
Hi there, i have an entry form with the following code on a command button to
add a new record. This button works for some users but not others, any ideas?
could it be a security setting?

Private Sub cmdAddnew_Click()
On Error GoTo Err_cmdAddnew_Click


DoCmd.GoToRecord , , acNewRec
Me!ProjectID = DMax("[ProjectID]", "[MainTracking]") + 1
Are the project ID's simply numbers that increment by one? If so, have you
looked at changing the field type to Autonumber? Doing so will eliminate the
need to do a DMax() and avoid any conflicts from two users adding a record at
the same time. If you do have to use DMax() you can set the control's default
value to the expression as in =DMax([whatever])
Me.Project_Pre2007 = Me.ProjectID
Me.LinkToReport = "E:\Library\Reports\" & [Project#Pre2007] & ".pdf"
Why is the variable named Project#Pre2007 when the variable above is
Project_Pre2007?
Me.DateEntered = Date
Do you have a control on the form that displays the value in the DataEntered
field? If so, set the DefaultValue to =Date()
 

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