Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 15th, 2005, 02:25 AM
fcm1357 fcm1357 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 8 fcm1357 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h
Reputation Power: 0
Question save records problems ...

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

Reply With Quote
  #2  
Old February 15th, 2005, 05:06 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 4
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

Reply With Quote
  #3  
Old February 15th, 2005, 06:14 PM
fcm1357 fcm1357 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 8 fcm1357 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h
Reputation Power: 0
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.

Reply With Quote
  #4  
Old February 16th, 2005, 12:53 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 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

Reply With Quote
  #5  
Old February 16th, 2005, 01:08 PM
alex_lee822 alex_lee822 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 43 alex_lee822 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 15 sec
Reputation Power: 4
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.

Reply With Quote
  #6  
Old February 17th, 2005, 05:18 AM
narcis_dev narcis_dev is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 1 narcis_dev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 42 sec
Reputation Power: 0
Cool

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..

Reply With Quote
  #7  
Old February 17th, 2005, 04:57 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 4
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

Reply With Quote
  #8  
Old February 21st, 2005, 12:43 AM
fcm1357 fcm1357 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 8 fcm1357 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h
Reputation Power: 0
Thank you guys

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > save records problems ...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway