Save button 07-06-07

How can I get the form to save data only by pressing the save button and not
by closing the form. Also, when I click the save button I want the form to
save the record and move on to a blank form ready for the next record and
place the cursor in the first field. 

I also want the form to ask upon closing if I want to save the data if I
haven't already saved it. 

Regards.

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200707/1

0
injanib
7/6/2007 12:26:38 PM
access.formscoding 7493 articles. 0 followers. Follow

4 Replies
725 Views

Similar Articles

[PageSpeed] 58

On Jul 6, 7:26 am, "injanib via AccessMonster.com" <u35551@uwe> wrote:
> How can I get the form to save data only by pressing the save button and not
> by closing the form. Also, when I click the save button I want the form to
> save the record and move on to a blank form ready for the next record and
> place the cursor in the first field.
>
> I also want the form to ask upon closing if I want to save the data if I
> haven't already saved it.
>
> Regards.
>
> --
> Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200707/1

Access has two main methodologies; Access proper and Visual Basic for
Applications.  Anytime you assign a recordset to a form, you are using
Access proper and must abide by Access rules.  I find this very
restrictive, so I almost exclusively use VBA.  It requires more
coding, but you gain a great deal of control over the finished
product.
To use VBA, open the recordset in the Form_Load event instead of
assigning it to the form recordsource property.  Here is an example:
Private Sub Form_Load()
   Set db = CurrentDb()
   Set rsSomeTable = db.OpenRecordset("tblSomeTable", dbOpenDynaset)
   If Not rsSomeTable.EOF Then
      DisplayRecord
   End If
End Sub

Put the following references at the top of the form code:

Private db as DAO.Database
Private rsSomeTable as DAO.Recordset

And be sure to close the database and the recordset in the Form_Unload
event:
Private sub Form_Unload()
   rsSomeTable.close

End Sub


0
OldPro
7/6/2007 3:27:27 PM
Sorry, I wasn't quite finished...

> Private sub Form_Unload()
>    rsSomeTable.close
>
> End Sub

Private sub Form_Unload()
   rsSomeTable.close
   set rsSomeTable = Nothing
   db.close
   set db = Nothing
End Sub

The code to add or edit a record is simple:

Private sub cmdAdd()
   rsSomeTable.Addnew   ' Note: .Addnew to Add, .Edit to edit
   rsSomeTable!ID=100
   rsSomeTable!FirstName = txtFirstName
   rsSomeTable!LastName = txtLastName
   rsSomeTable.Update
End Sub

0
OldPro
7/6/2007 3:33:15 PM
I am sorry, but I am working on my very first Access project and am not very
familiar with it. Here is the part of your answere I don't quite understand.
Please elaborate a little more. 

"To use VBA, open the recordset in the Form_Load event instead of
assigning it to the form recordsource property.  Here is an example:
Private Sub Form_Load()
   Set db = CurrentDb()
   Set rsSomeTable = db.OpenRecordset("tblSomeTable", dbOpenDynaset)
   If Not rsSomeTable.EOF Then
      DisplayRecord
   End If
End Sub"


OldPro wrote:
>> How can I get the form to save data only by pressing the save button and not
>> by closing the form. Also, when I click the save button I want the form to
>[quoted text clipped - 8 lines]
>> --
>> Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200707/1
>
>Access has two main methodologies; Access proper and Visual Basic for
>Applications.  Anytime you assign a recordset to a form, you are using
>Access proper and must abide by Access rules.  I find this very
>restrictive, so I almost exclusively use VBA.  It requires more
>coding, but you gain a great deal of control over the finished
>product.
>To use VBA, open the recordset in the Form_Load event instead of
>assigning it to the form recordsource property.  Here is an example:
>Private Sub Form_Load()
>   Set db = CurrentDb()
>   Set rsSomeTable = db.OpenRecordset("tblSomeTable", dbOpenDynaset)
>   If Not rsSomeTable.EOF Then
>      DisplayRecord
>   End If
>End Sub
>
>Put the following references at the top of the form code:
>
>Private db as DAO.Database
>Private rsSomeTable as DAO.Recordset
>
>And be sure to close the database and the recordset in the Form_Unload
>event:
>Private sub Form_Unload()
>   rsSomeTable.close
>
>End Sub

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200707/1

0
injanib
7/6/2007 8:39:45 PM
I have added a few notes to the previous message:

On Jul 6, 3:39 pm, "injanib via AccessMonster.com" <u35551@uwe> wrote:
> I am sorry, but I am working on my very first Access project and am not very
> familiar with it. Here is the part of your answere I don't quite understand.
> Please elaborate a little more.
>
> "To use VBA, open the recordset in the Form_Load event instead of
> assigning it to the form recordsource property.  Here is an example:
> Private Sub Form_Load()

db has previously been declared as a database; here we are assigning
the current database to it, i.e. the actual Access project.

>    Set db = CurrentDb()

rsSomeTable (or whatever name you choose) has already been declared as
a recordset; here we are assigning it to a table.  dbOpenDynaset
allows viewing and editing.

>    Set rsSomeTable = db.OpenRecordset("tblSomeTable", dbOpenDynaset)

We cannot display a record if the recordset is empty, so we must test
it first.  Recordsets always open to the first record, if there is
one.  Otherwise the End of File (.EOF) is set to true.

>    If Not rsSomeTable.EOF Then

Finally, you will need a function to display the record on the
screen.  I put in DisplayRecord as a placeholder... you will have to
write your own function.  Basically you will just assign each field in
the recordset to a textbox on the screen:   txtSomeTextBox=rsSomeTable.
[SomeField]

>       DisplayRecord
>    End If
> End Sub"
>
>
>
>
>
> OldPro wrote:
> >> How can I get the form to save data only by pressing the save button and not
> >> by closing the form. Also, when I click the save button I want the form to
> >[quoted text clipped - 8 lines]
> >> --
> >> Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200707/1
>
> >Access has two main methodologies; Access proper and Visual Basic for
> >Applications.  Anytime you assign a recordset to a form, you are using
> >Access proper and must abide by Access rules.  I find this very
> >restrictive, so I almost exclusively use VBA.  It requires more
> >coding, but you gain a great deal of control over the finished
> >product.
> >To use VBA, open the recordset in the Form_Load event instead of
> >assigning it to the form recordsource property.  Here is an example:
> >Private Sub Form_Load()
> >   Set db = CurrentDb()
> >   Set rsSomeTable = db.OpenRecordset("tblSomeTable", dbOpenDynaset)
> >   If Not rsSomeTable.EOF Then
> >      DisplayRecord
> >   End If
> >End Sub
>
> >Put the following references at the top of the form code:
>
> >Private db as DAO.Database
> >Private rsSomeTable as DAO.Recordset
>
> >And be sure to close the database and the recordset in the Form_Unload
> >event:
> >Private sub Form_Unload()
> >   rsSomeTable.close
>
> >End Sub
>
> --
> Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200707/1- Hide quoted text -
>
> - Show quoted text -


0
OldPro
7/6/2007 9:05:05 PM
Reply:

Similar Artilces:

Forms 07-27-07
Hi, A VB Code is used that has the following line: Me.Visible = False (Me refers to the forms names frmBirthsearch) After this line a second form (form2) is opned based on a query that reads two dates from the frmBirthsearch using the line code: DoCmd.OpenForm "frmBirthdates", acViewNormal at this point frmbearthsearh is hidden. What command shold I add after this in order to close the frmbirthsearch? ...

WM_QUERYENDSESSION and saving data through a worker thread
Hello I have an application that uses a worker thread to save/load data. I'm wondering what is the best reaction to WM_QUERYENDSESSION in my case. I have to possible scenarios: 1. When WM_QUERYENDSESSION comes fire the thread and wait for it to end. Only then return TRUE from WM_QUERYENDSESSION handler. The problem is that I will get nusty dialog that my application "is not responding". 2. When WM_QUERYENDSESSION comes fire the thread and return FALSE from the handler. When thread is done force application to end. But this way I will probably prevent Windows from closing,...

O2003 New Toolbars Saved Where?
I have XP with O2003 on one computer. Just got a new computer with W7 and installed O2003. I copied over the "outcmd.dat" file and I can see my data (e.g. views) so I know its using the correct "outcmd.dat" file. However two custom toolbars I created are not shown nor are they in the customized toolbar list. Are custom toolbars saved in a different location? Thanks Shawn On Jul 24, 6:22=A0pm, srm <s...@primatech.com> wrote: > I have XP with O2003 on one computer. Just got a new computer with W7 > and installed O2003. I copied over the "outcmd.dat" ...

Keeping a table in a form editable and checking that fields are filled in before allowing a save
Firstly apologies if this is the incorrect forum but I was looking for a general word forum and could not find one. Please point me to one if one exists. I am trying to create a form where I want to specify what items need to be filled in. (Review minutes from design reviews). I want to make certain fields mandatory like the date, attendees and check list used and want to block saving of the document with a warning until they are filled in. Is there a way of doing this? Also as a part of the review actions are filled in to a table. depending on how many actions there are the table...

Problems opening/saving attachments
I am unable to open or save any .rtf file attachments - this started happening today, previously there were no problems with .rtf files. When I try to open such an attachment I get this message: Can't create file: xyz.rtf Right click the folder you want to create the file in, and then click Properties on the shortcut menu to check your permissions for the folder. What folder is this? I am trying to open the attachment not creat the file! Also, when I try to send an rtf file as an attachment, in the email message the file does not show in the attachments section but the receipient actu...

Saving address to replyed emails
IN outlook express I could automatically save the email address when I replyed to an email. I want to be able to do this in outlook 2002 Can some please help Not possible. You will need to right click on the address and select to Add to Contacts. -- Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Having searched the archives, Garth <smilepolice@hotmail.com> typed: | IN outlook express I could automatically save the email | address when I replyed to an email. | | I want to be able to do this in outlook 2002 | | Can some please help ...

Middle mouse button does not always open in new tab anymore
Hi! I am experiencing the problem that when I click with the middle mouse button on a link (for example google search results) it does not always open it in a new tab anymore. In about 20% of the cases it takes over the current tab instead. The same problem is explained here in german: http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.de.internetexplorer&tid=cd463718-8df6-4ee4-9e8a-9ee527837f83&cat=&lang=de&cr=DE&sloc=&p=1 But since there was no answer found so far I decided to take it to the next level (english c...

Outlook saves image attachment as bitmap
Hi. I have Outlook 2003 running on Windows XP. When I save an image attachments, it only allows me to save it as bitmap. Before, it used to let me choose between bitmap & jpeg. I found an article on Microsoft's website, but it only pertains to Internet Explorer (http://support.microsoft.com/?kbid=810978#appliesto). I did it anyways, but it didn't correct my problem. Thanx in advance, Candee ...

M2004 Won't Save Customized Toolbars / Home Page
Unable to find anything in archives or the UFAQ on this... My Money 2004 file recently stopped saving customized toolbars / home page. Any changes I make don't "stick". I've used super salvage, which supposedly found and corrected some errors, but the problem persists. Any ideas? Thanks. Try this (and it is in the UFAQ under a less specific topic at http://umpmfaq.info/faqdb.php?q=153). Stop Money Express. Change your toolbar stuff. Exit Money. Restart Money. Restart Money Express. "Sock" <sock@wideopenwest.com> wrote in message news:8205f05b.04101407...

Email Text Dissappears when Save
When we save email messages (as a draft) the text dissappears, even when th I use my administrator account. Anybody have any idea what that is happening. ...

Prevent users from saving music and pictures to their hard drives without folder redirection?
Hi there. I'm wondering if there is a way via GPO or anything else to prevent users from saving music and pictures to their local hard drives without using any type of profile or folder redirection. Thanks. ...

Adding a button with a function on protected sheets.
How do i add a button to 'reset/clear' the data on a worksheet that is protected and uses VLookup data (from another worksheet). Everyday this table will have data chosen from combo boxes or manually entered in allowable editable fields and at the end of the day after the files is saved, I need to clear that data for use on the next day. How is this Reset button applied with allowable edit ranges, VLookup data and a protected worksheet? Thanks There's several ways to do this. 1. Instead of straight vlookups, use =IF(ISBLANK(VLOOKUP(....)),"",VLOOKUP(....)) wher...

Saving MY Calendar into "Publication-Calendar"
My problem is that I have to make a certain type of calendar in every month. It would save lots of time forme if I could find a way that I could save my "calendar setting" and also be able to apply the new month's settings. There is any way that I could save my "home-made" calendar into "Publications-Calendar" and call it up just like the other calendars? Thanks. If you have repeating items you just use the Merge for those items every month. -- "If you don't know where you are going, any road will take you there!" I do not understand ho...

Routing Restrictions button unavailable (gray) no matter what options selected in IMS-->Routing tab
I am running Exchange 5.5 SP4. In Connections-->IMS-->Routing Tab, my "Routing Restrictions" button is unavailable (greyed-out) no matter what options I select. Any suggestions? Thank you. Try installing Exch Admin prog on other machine, apply SP4 and see if you can change it from there. Post back with details. ryanadmin wrote: > I am running Exchange 5.5 SP4. In Connections-->IMS-->Routing Tab, my > "Routing Restrictions" button is unavailable (greyed-out) no matter > what options I select. Any suggestions? Thank you. ...

Save custom formats independantly of workbooks?
Hi, Is there a way to save several custom formats (say, numbers in $000's, in $ millions, etc) which I would use for a variety of workbooks (including workbooks where those formats do not exist yet), with a name, and make them accessible from the toolbars? Earlier today someone kindly suggested to assign a name to the format using Format -> Style, but the formats I had saved have disappeared from the style menu once I closed a spreadhseet and used a different one. Any suggestion? Many thanks, Joss Delage ...

Saving as web page
When publishing spreadsheets as web pages I would like to set the page to fit within a full screen view. I have some that fit and some that don't and I've worked with the formats in Excel to fit everything within the screen on all of them, but that doesn't seem to help. Can I set the format to do this? Thank you in advance for your assistance. Jeff ...

Command Button to Sort and Filter by Selection
Is it possible to create a command button on a form that will allow you to sort records or to use the Filter by Selction option? They are not choices I can select while using the wizard or the macro builder. However, both of these would be extremely useful as I'm building a database for someone who has never used a database before and isn't all that comfortable with computers in general. I am using Access 2003 and I am NOT familiar with Access Visual Basic, Java or building macros from scratch. I'm sure there is a way to use these tools to create what I want, ...

How do I work in excel and then save it as a doc or docx?
I need to be able to work in excell and then save it in doc or docx format. If I cannot do this, can I make doc or docx so that I can use the automatic sum? In Word, you can use AutoSum of the Tables and Borders toolbar to sum the values in table. But when you change the values, you need to right-click the total value to refresh it. It can not update auto. Lee Li Fong http://smartusemicrosoftoffice.blogspot.com/ Hi Nadine, You can open a Word document and Insert -> Object -> Microsoft Excel Worksheet Ed Ferrero www.edferrero.com ...

PDF attachments 06-21-10
I cannot open a PDF attachment directly from WLM. If I save it to my desktop then I can open it. Is that just the way it is? PDF attachments in OE6 used to work. I am running Vista. Help! Ed This fix only mentions Windows Mail but it should apply equally to Windows Live Mail : http://www.winhelponline.com/articles/236/1/Unable-to-open-PDF-attachments-from-Windows-Mail.html Gary VanderMolen, Microsoft MVP (Mail) "Ed Ahern" wrote in message news:e33LaPOELHA.4824@TK2MSFTNGP05.phx.gbl... I cannot open a PDF attachment directly from WLM. If I save it to my ...

Excel 2000 crashes Win98 when I save. All reloads failed.
I'm running Office 2000 and Windows 98. Excel crashes badly when I save. Two Ctrl-Alt-Deletes get me as far as "exit excel" but that doesn't work. I always have to reboot. I have reloaded Windows 98 twice. I have removed Office 2000 completely and then reloaded it, again twice. I don't have antivirus software on this machine. Other machines with antivirus aren't detecting any virus activity on my zip disk files. I at least have a router and I don't use MS Outlook, which cuts down on viral attacks. Yahoo mail screens incoming email files. Is there s...

After update 10-31-07
I'm using an After Update event on a form to update one field with the current date when a checkbox is checked, but the date doesn't display until I scroll down the form. Is there some way to get the date to display right after the box is checked (or at least once the next record is selected)? Thanks, Tom -- Thanks, Tom Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200710/1 Sounds like you have a control that has a Name that is different from the name of the date field. In the AfterUpdate code, use the name of the control,...

Saving a scrollable image in bitmap and jpeg format
I have a picture control in which i am diaplaying images of various sizes if size go beyond the size of the dialog then scrollbars becomes active so view the hidden image. But when wriiten two functions to save that bitmap following problems occured: 1> For the first function it was saving only viewable area of teh bitmap 2> for second if i have specified the dimensions as 800 X 600 and picture control diamensions is 345 X 330 then it is taking area outside dialog to get image of the 800 X 600 How can i save the image with same dimensions with which i am displaying it ? Thanking in ant...

RESUME 05-20-07
JACQUELINE BENOIT 1792 NW 20TH AVE. FT Lauderdale FL. 33311 954-479-9110 954-636 1305 OBJECTIVE: To obtain a position as a Medical assistant that allows the use and expansion of my training and skills. EDUCATION: National School of Technology Diploma, Medical Assisting 2/07 Nursing: Florida Academy of Health and Beauty Wilton, Manors. FL CLINICAL SKILLS: Venipuncture EKG's Vital Signs Autoclave /Urinalysis Specimen Collection ADMINISTRATIVE SKILLS: Knowledge of medical terminology Phone Triage Front Office Skills Appointment Setting Medisoft CPT/ICD-9 coding Medica...

Excel won't save
Just started to have a problem with Excel not saving my work. I have a worksheet set up to do my invoicing. When I'm done inputing my new information and before I close; I; of course will want to save. If I press the "Save" icon in the tool bar, Excel will show that it is saving the worksheet in the lower tool bar. It will say "saving Master Invoice" and then ready. If I close and re-open the worksheet; I will find that nothing was saved. I have tried using the menu item "File" and then "Save as" and I get the same results. My only saving grac...

"New" button activates send/receive
When I click the Send/Receive button, nothing happens. However, when I click the "New Message" button, in comes all my new messages. Also, the auto Send/Receive under Options (every 1 minute) is not working at all. Any thoughts on how to fix this? Much Appreciated, Dave ...