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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AllowEdits false failing = confusion

Status
Not open for further replies.

MePenguin

Technical User
Oct 31, 2003
107
SE
I have a button on a subform to allow the user to edit the current record. By default the subform is set to AllowEdits =false, and the button is coded:

Code:
Private Sub ButEditDate_Click()
'Allow edits for subform, and changes edit button to a 'save' button

If Me.ButEditDate.Caption = "Edit Date" Then
    Me.Form.AllowEdits = True
    Me.ButEditDate.Caption = "Save Date"
    Me.BoxLabNr.SetFocus
Else
    Me.ButEditDate.Caption = "Edit Date"
    Me.Form.AllowEdits = False
End If

End Sub

So it should work as a simple toggle to allow/deny editing of the existing data...

The problem is that when it is in 'Save Date' mode and is clicked the controls on the form remain editable... even though I can confirm that allowedits=false (Immediate window).

Is there something I'm missing? Should I send a save record command before allowedits=false? Is it enough to have the form set to allowedits=false in design view or do I need to force it to this OnOpen?

Help please?

Phil

Phil

---------------
Pass me the ether.
 
OK, answered my own question...
I put
Code:
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
(code generated by control wizarding a 'save record' button)in after the else, and it works fine.

I don't like DoMenuItem... is there a better way of coding a save record command?

Thanks

Phil

Phil

---------------
Pass me the ether.
 
Yes,
[tt]DoCmd.RunCommand acCmdSaveRecord[/tt]

but do also have a look at Losing data when you close a form for pros and cons of different methods.

Also - wouldn't this be more a forms question (forum702) than Access Modules/VBA Coding ;-)

Roy-Vidar
 
Thanks for the tip and the link - very useful!

You're right about the cross posting, sorry, didn't seem so obvious when I was writing it.

Phil

Phil

---------------
Pass me the ether.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top