Save Or Delete By Buttons Only

samm

Registered User.
Local time
Today, 00:35
Joined
Sep 19, 2003
Messages
27
Hi

I have save button and delete button in the form but the record save and delete without button.

Who know how I make it save and delete record by button only?


__________________
thanks
 
If you close the form without pressing either of your buttons then the record will save regardless.

A form level variable:

Code:
Private booFormLock As Boolean


On the Save button's Click event:

Code:
DoCmd.RunCommand acCmdSaveRecord
booFormLock = True
DoCmd.Close acForm, Me.Name

On the Cancel button's Click event:

Code:
Me.Undo
booFormLock = True
DoCmd.Close acForm, Me.Name

On the Form's Unload event:

Code:
If Not booFormLock Then Cancel = True
 
thank you Mile-O-Phile

I use this code:
____________________________________________
Option Compare Database
Private booFormLock As Boolean

Private Sub CmdSave_Click()
On Error GoTo Err_CmdSave_Click
DoCmd.RunCommand acCmdSaveRecord
booFormLock = True
DoCmd.Close acForm, Me.Name

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_CmdSave_Click:
Exit Sub

Err_CmdSave_Click:
MsgBox Err.Description
Resume Exit_CmdSave_Click

End Sub

____________________________________________

still not save by button and the form unable to close
 
samm said:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

That line is obsolete.

What version of Access are you using?
 
You've already saved the record with the DoCmd.RunCommand, you don't need the DoMenuItem as well, which as Mile says is obsolete anyway
 
I get this code form your example:
________________________________

Option Compare Database

Dim booFormLock As Boolean

Private Sub cmdCancel_Click()
Me.Undo
booFormLock = True
DoCmd.Close acForm, Me.Name
End Sub

Private Sub cmdConfirm_Click()
DoCmd.RunCommand acCmdSaveRecord
booFormLock = True
DoCmd.Close acForm, Me.Name
End Sub

Private Sub Form_Load()
' default the form to a new record each time
DoCmd.GoToRecord , , acNewRec
End Sub

Private Sub Form_Unload(Cancel As Integer)
If Not booFormLock Then Cancel = True
End Sub
______________________________

I have access 2000

these name for wich button.

cmdCancel
cmdConfirm

I created button and I look for cancel and contfirm button but I can n't see any buttom like them.


sorry about not understand.
 
I'm sorry but I do not understand.

In my example the two command buttons at the bottom of the form are cmdConfirm and cmdCancel (left to right, respectively.)
 
After several days i found this Threat

Sj McAbney thanx...

U save me man...With this post

:):)

I'm OBLIGATED

Johann
 

Users who are viewing this thread

Back
Top Bottom