Having a Save and Edit Button on a form.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I need some help with a problem I have, can anyone help?

My problem is that I want one of my forms to have a 'Save' and 'Edit'
button. How I want them to work (If possible) is to have it when I click on
'Save', it disables all of the fields in that record and you can't edit
anything. once i click the 'Save' and move on to the next record, I want to
have the same option for that record (be able to save individual records).
The only way to undo the 'Save' button would be to click the 'Edit' button to
enable and edit the fields. How can that be done? I would really appericate
the help.
 
Use the Save button Click event to set AllowEdits = False, and the Edit
button Click event to set AllowEdits = True.
hth
Al Camp
 
Thank you Al Camp,

I got the Save and Edit working, but my next problem, is how do i get the
save and edit to work on each individual record?
Here is the code that i have for both the Save and Edit:

+++ Save +++
===========================
Private Sub cmdSaveRecord_Click()

If intCanEdit = IFalse Then
With frm
Me.AllowAdditions = False
Me.AllowDeletions = False
Me.AllowEdits = False
End With
Else
With frm
Me.AllowAdditions = True
Me.AllowDeletions = True
Me.AllowEdits = True
End With
End If

End Sub
===========================
+++ Edit +++
===========================
Private Sub cmdEditRecord_Click()

If intCanEdit = IFalse Then
With frm
Me.AllowAdditions = True
Me.AllowDeletions = True
Me.AllowEdits = True
End With
Else
With frm
Me.AllowAdditions = False
Me.AllowDeletions = False
Me.AllowEdits = False
End With
End If

End Sub
===========================

How can i get this to work on the individual records? or how would i
re-phrase the code so i can put in under the "Form_Current" code?

I found the code under the Microsoft Visual Basic Help by typing in AllowEdit.
Thanks again,
Jay
 
The code is
save button
DoCmd.RunCommand acCmdSaveRecord
or
If Me.Dirty = True Then Me.Dirty = False
Me.allowedits = false

Edits button
Me.allowedits = true

Chris
 
I answered according to what I thought you wanted to do, but I think the
whole Save and Edit button thing is not the way to go. Clicking a button to
lock or unlock a record doesn't set any indication as to what state the
record is when you land on it. Using your method, when you arrive on a
record, you have no idea whether that record is locked or not... but, you
asked for a button to force the form into Edit mode... or Save mode

Perhaps you should add a field to your table called Locked (True/False).
When you want Lock a record, check Locked... or uncheck it to allow editing.
Now we can make a logical decision using the OnCurrent event of the form....
If Locked = True Then
Me.AllowEdits = False
Else
Me.AllowEdits = True
End If

And on the Locked AfterUpdate event...
If Locked = True Then
Me.AllowEdits = False
Else
Me.AllowEdits = True
End If

Then you can dump the Save and Edit buttons altogether...
hth
Al Camp
 
Back
Top