B
bertenbert via AccessMonster.com
Dear all,
I'm creating a database (for making invoices) with several forms based on
several tables and queries.
My goal is the following:
I want to protect the data on the forms (or more correct: of the underlying
tables) against accidentally changing.
I have created the database for different users and some of them might change
data without wanting to change anything.
I have therefor set the properties of all forms as follows:
allow edits = No
allow deletions = Yes
allow additions = No
Data Entry = No
I have also provided for several command buttons on the forms.
Goal is that people can only add data when they push the command button "add"
and that they can only edit data when they push an edit button.
After having edited or added data they should push a save button.
People must also be able to save a record when they have only filled in (when
adding a new record or changing an existing record) some of the data fields
on the form.
If I may I'll write down the code for the different command buttons.
Maybe you could tell me if they're correct?
COMMAND BUTTONS
For each button there's:
Private Sub ... CliCk()
On Error GoTo Err_..._Click
CODE (SEE AFTER PLEASE)
Exit_..._Click:
Exit Sub
Err_..._Click:
MsgBox Err.Description
Resume Exit_..._Click
End Sub
I guess this was classic, but now code itself
1) ADD (this button works fine)
Me.AllowAdditions=True
DoCmd.GoToRecord, ,acNewRec
[...].SetFocus
2) DELETE (this button does not work)
DoCmd.DoMenuItem acFormBar,acEditMenu,8 ,acMenuVer70
DoCmd.DoMenuItem acFormBar,acEditMenu,6 ,acMenuVer70
3) EDIT (works)
Me.AllowEdits=True
[...].SetFocus
4) Save (works after editing, but not after adding)
If Me.Dirty Then Me.Dirty= False
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,acMenuVer70
[...].SetFocus
Problem with the buttons above:
1) After having edited a record the record is saved when using the button
save.
But after adding a new record the record is not saved: there's following
error message "the command or action 'SaveRecord' isn't available now.
One more detail about saving: when I use the close button after editing or
adding a record the data is always saved.
The button "save"thus only partially work.
2) Also the command button "delete record" does not work. When pushing the
button, there no error message, but nothing happens.
Kind regards and many thanks for help already,
Bert
I'm creating a database (for making invoices) with several forms based on
several tables and queries.
My goal is the following:
I want to protect the data on the forms (or more correct: of the underlying
tables) against accidentally changing.
I have created the database for different users and some of them might change
data without wanting to change anything.
I have therefor set the properties of all forms as follows:
allow edits = No
allow deletions = Yes
allow additions = No
Data Entry = No
I have also provided for several command buttons on the forms.
Goal is that people can only add data when they push the command button "add"
and that they can only edit data when they push an edit button.
After having edited or added data they should push a save button.
People must also be able to save a record when they have only filled in (when
adding a new record or changing an existing record) some of the data fields
on the form.
If I may I'll write down the code for the different command buttons.
Maybe you could tell me if they're correct?
COMMAND BUTTONS
For each button there's:
Private Sub ... CliCk()
On Error GoTo Err_..._Click
CODE (SEE AFTER PLEASE)
Exit_..._Click:
Exit Sub
Err_..._Click:
MsgBox Err.Description
Resume Exit_..._Click
End Sub
I guess this was classic, but now code itself
1) ADD (this button works fine)
Me.AllowAdditions=True
DoCmd.GoToRecord, ,acNewRec
[...].SetFocus
2) DELETE (this button does not work)
DoCmd.DoMenuItem acFormBar,acEditMenu,8 ,acMenuVer70
DoCmd.DoMenuItem acFormBar,acEditMenu,6 ,acMenuVer70
3) EDIT (works)
Me.AllowEdits=True
[...].SetFocus
4) Save (works after editing, but not after adding)
If Me.Dirty Then Me.Dirty= False
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,acMenuVer70
[...].SetFocus
Problem with the buttons above:
1) After having edited a record the record is saved when using the button
save.
But after adding a new record the record is not saved: there's following
error message "the command or action 'SaveRecord' isn't available now.
One more detail about saving: when I use the close button after editing or
adding a record the data is always saved.
The button "save"thus only partially work.
2) Also the command button "delete record" does not work. When pushing the
button, there no error message, but nothing happens.
Kind regards and many thanks for help already,
Bert