Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command button: turn on/off edit mode 1

Status
Not open for further replies.

jlmeek

Technical User
Jan 30, 2001
13
US
Is there any way to stop Access from returning to the first record when a command button turning on the edit mode is clicked? For example, if a user is browsing the database via the form and comes upon a record that needs to be updated and clicks on the turn on edit mode button she invariably is returned to the first record in the database. I want it to remain on the record needing to be updated. See code below:
'Turn on or off AllowEdits, AllowAdditions and AllowDeletions.
'Change button's caption

If Me.AllowAdditions = True Then
With Me
.AllowAdditions = False
.AllowDeletions = False
.AllowEdits = False
End With
Me.cmdEditMode.Caption = "Edit Mode Off"

Else
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With

Me.cmdEditMode.Caption = "Edit Mode On"

End If

Me.Requery 'reloads the data on the form to the current setting
 
You're problem lies with 'Me.Requery'. You shouldn't need to requery the form. Simply turning the properties back on should be sufficient.
 
Hi Jerry,

Thank you for your suggestion; however, by deleting 'Me.Requery' from the event my edit on/off command button I created doesn't work properly. For example, my user is browsing the database she comes upon a record that needs to be updated so she clicks the button to turn on the edit mode - makes her changes (without the Me.Requery she remains on the record needing updating) and then wants to turn off the edit mode by clicking the button again to continue browsing in a read-only mode. Without the Me.Requery line the edit mode does not turn off. Any other suggestions?

I hope this wasn't too unclear.

Thanks jerry,
jess
 
Place this in your forms on current event
With Me
.AllowAdditions = False
.AllowDeletions = False
.AllowEdits = False
End With


and this in your command buttons on click event
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Me.cmdEditMode.Caption = "Edit Mode On"

when the button is clicked they can edit the record but as soon as they go to next record the edit mode will be turned off
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top