|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi,
How to set a bounded form to a blank form when open the form and also after saving the information? I use the wizard to create an "save" button, it did work but how come the information will be saved also when i close the form even though i do not press the save button? where might be gone wrong? Thanks |
|
#2
|
|||
|
|||
|
Didn't do anything wrong at all. By default the record is always saved as soon as you loose the focus. So adding a save button would be used if you don't want to leave the current record, yet save what has been entered up to that point. To move to a blank form, means you want to move to a new record. So if you want the form to open as a new record, set the Data Entry to Yes in the forms property. You can also use the DoCmd.GoToRecord,,,acNew in your Save button as well to go to a new record after saving the current record.
lwells |
|
#3
|
|||
|
|||
|
oic, so is it possible that i can set not to save automatically until i press the save button? Which means if i press the close button or quit in half way the record will not be saved.
|
|
#4
|
|||
|
|||
|
NO, once you have entered any information into a record, when you close the form that information will be saved automatically. Saving a record during data entry is sometimes neccessary for certain functions or code to run. Otherwise once you leave the record any portion that was already entered is automatically saved to the table.
lwells |
|
#5
|
|||
|
|||
|
Um.. I think there is one way you can just "tell" access to forget about whatever you did to the form since you have saved it last.
lwells.. do you remember the Me.Dirty Undo function? I don't but I've used it before. It's like a function where it will compare the newly edited version of the record with the old one.. and if it's different in anyway.. it will undo all the edits.. you might incorporate into a "Disgard Changes and Close" button. |
|
#6
|
|||
|
|||
|
Hi,
I used unbounded form and [Save] button to add new record MyTable - mdb table with 3 fields Nr, Name, tel 1 form 3 textboxes: txtNr, txtName, txtTel and a button [Save] cmdSave here is the code : Code:
Private Sub cmdSave_Click()
' error stuff
On Error GoTo Err_cmdAddNew_Click
' recordset using DAO
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("MyTable", dbOpenTable)
' new record - use rst.Update if u like to update records (edit)
rst.AddNew
rst!Nr = Me!txtNr
rst!Name = Me!txtName
rst!Tel = Me!txtTel
rst.Update
rst.Close
'
Set rst = Nothing
' cleaning textboxes to add a new record
Me!txtNr = ""
Me!txtName = ""
Me!txtTel = ""
'error message stuff
Exit_cmdAddNew_Click:
Exit Sub
'error message stuff
Err_cmdAddNew_Click:
MsgBox ("Horror :" & Err.Description & " Source: " & Err.Source)
Resume Exit_cmdAddNew_Click
End Sub
this way u can add new records only if push the [ Save ] (cmdSave) button hope helps.. |
|
#7
|
|||
|
|||
|
Again....you will always create the record once you have started entering data into a control when you are at a new record. You can always delete the record if you don't want to keep it, but when you close your form, you will find whatever was entered will be in your table otherwise. The OnDirty event can be used to undo data that has been changed to an existing record.
The prior post will add records only if the controls are unbound, but as long as you are using bound controls on your form...you will create a record. lwells |
|
#8
|
|||
|
|||
|
Thank you guys
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > save records problems ... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|