not save information (1 Viewer)

stabesh

New member
Local time
Today, 14:44
Joined
Dec 13, 2010
Messages
5
hi
I want information not save in the current table in form until command button clicked
thanks
 

DCrake

Remembered
Local time
Today, 22:44
Joined
Jun 8, 2005
Messages
8,626
You may need to build an unbound form to accomplish this efficiently.
 

vbaInet

AWF VIP
Local time
Today, 22:44
Joined
Jan 22, 2010
Messages
26,374
Records only get saved when you move from one record to the other.
 

vbaInet

AWF VIP
Local time
Today, 22:44
Joined
Jan 22, 2010
Messages
26,374
The same way, if you change record 1, it will save only when you move to record 2, or 3 or 4... etc
 

stabesh

New member
Local time
Today, 14:44
Joined
Dec 13, 2010
Messages
5
I have not saved data until click 'ok'
and Do not save anything when click 'cancel'
in form and subform
 

Attachments

  • DemoSaveA2000.zip
    28.9 KB · Views: 75

ghudson

Registered User.
Local time
Today, 17:44
Joined
Jun 8, 2002
Messages
6,194
Check out the programming for saving, undo and testing if a record is dirty [has been modified but not saved] in my old A Better Mouse Trap? sample which should help your quest.
 

stabesh

New member
Local time
Today, 14:44
Joined
Dec 13, 2010
Messages
5
hi
I'm find it
Is exist any better way ?
thanks
 

Attachments

  • DemoSaveA2000.zip
    52.6 KB · Views: 74
Last edited:

Saint34

Registered User.
Local time
Today, 17:44
Joined
Jun 23, 2010
Messages
16
If you create a new record and switch to a different record it will save what you have done. However if you want a cancel button then add a button and in the code on click just put this:
Me.Undo
Do.cmd.close

When you hit the button it will cancel what you have done and close the current form. If you want it to reload you can simply put in a do.cmd.open "[Form]" at the end.

-Saint
 

Dairy Farmer

Registered User.
Local time
Tomorrow, 00:44
Joined
Sep 23, 2010
Messages
244
Set the form properties to Allow Additions = No
On the form have a button to add a new record

Code:
Private Sub Button_New_Click()
Dim rst As DAO.Recordset

[COLOR="SeaGreen"]'Allows you to add a record[/COLOR]
    Me.AllowAdditions = True

[COLOR="SeaGreen"]'Creates a new record and goes to the first field[/COLOR]

    Set rst = Me.Recordset
        rst.AddNew
        rst.Update
    Me.[COLOR="Blue"]FirstField[/COLOR].SetFocus

[COLOR="SeaGreen"]'Disallows adding a record[/COLOR]

    Me.AllowAdditions = False
End Sub

On the last field have an On Exit (or a save button)
Code:
Private Sub [COLOR="blue"]LastField[/COLOR](Cancel As Integer)
    DoCmd.RunCommand acCmdSaveRecord
    Me.Requery
End Sub

The following can be used in the Save Button or Form Exit. It check to see if the record is New and Dirty (i.e you made a new record and entered something)
Code:
    If (Me.NewRecord And Me.Dirty) Then
                Msg = "Are you sure you want to discard this entry?"
                Style = vbOKCancel + vbQuestion + vbDefaultButton2
                Title = "Discard An Entry"
                Response = MsgBox(Msg, Style, Title)

            If Response = vbCancel Then
                MyString = "Cancel"
                Cancel = True
                DoCmd.GoToControl "[COLOR="Blue"]FirstField[/COLOR]"
                Me.AllowAdditions = False
            
            Else
                MyString = "OK"
                DoCmd.RunCommand acCmdUndo
                Me.AllowAdditions = False

            End If
    End If

[COLOR="Teal"]'Keep this bit if you want to discard a blank new record[/COLOR]

    If (Me.NewRecord And Not Me.Dirty) Then
            Me.AllowAdditions = False
    End If
 

Users who are viewing this thread

Top Bottom