My code stops after the record saves....form never closes

Users are going into to update a number, and they want to close the form 
before the record gets saved, thus losing their changes.

I created an Exit button, which should save the record change and close the 
form.  Here's the code:

If Me.Dirty Then
        RunCommand acCmdSaveRecord
    End If
    Forms![frmRMSHours]![Act Hours] = Me![Text9]

If the record is dirty, they press Exit and the record saves.  They have to 
press Exit again and the form closes.  If the record is not dirty, the form 
will close when pressing Exit.  What am I doing wrong?
4/21/2010 4:34:03 PM
access.formscoding 7493 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 44

To save a record, then close the form:

If Me.Dirty Then
  Me.Dirty = False
End If

DoCmd.Close acForm, Me.Name

This assumes you want to close the form that has the command button, not some
other form, in which case you would need:

DoCmd.Close acForm, "FormName"

Actually, you should be able simply to close in this way:


This closes the active window, but seems to me I've have some unexpected
results from doing it that way, so I specify what is to be closed.

I'm not sure what is going on here:

Forms![frmRMSHours]![Act Hours] = Me![Text9]

Is frmRMSHours the current form, another form, or what?  If another form, is
it open?  What is Text9?  In any case, you seem to be adding new data to the
record after saving it.  If you are going to do an explicit save, do so after
all new data has been added.

CCripe wrote:
>Users are going into to update a number, and they want to close the form 
>before the record gets saved, thus losing their changes.
>I created an Exit button, which should save the record change and close the 
>form.  Here's the code:
>If Me.Dirty Then
>        RunCommand acCmdSaveRecord
>    End If
>    Forms![frmRMSHours]![Act Hours] = Me![Text9]
>    DoCmd.Close
>If the record is dirty, they press Exit and the record saves.  They have to 
>press Exit again and the form closes.  If the record is not dirty, the form 
>will close when pressing Exit.  What am I doing wrong?

Message posted via

4/21/2010 5:19:07 PM

Similar Artilces:

Use Form to prompt for report criteria
I have a form that I am using to prompt for report criteria. When I run the query outside of the form, it works fine - prompting me for both criteria. However when I run from the form, I get #Error#. Can you see what I am doing wrong? Thanks in advance. I have two combo boxes that I have put in my underlying query. In the fields of the query are: [Forms]![frmSelection Criteria Form]![OfficeNumber] [Forms]![frmSelection Criteria Form]![Manager] *** On the OnClick event is the following: Private Sub Command6_Click() On Error GoTo Err_command6_Click Dim stDocName As String st...

Save formatted text from RichEdit control to rtf-file
Hi , How can I save the text from Rich edit control (2.0) to *.rtf , *.txt , *.doc I tried to get the buffer and putting the buffer to file, then saving the file but the text in the file is something different. Please let me know what to do? Here is the Code I ma using: mFile.Seek( 0, CFile::begin ); CString cBuffer2; int iTotalTextLength = m_oChatMessageControl.GetWindowTextLength(); HWND focusWnd = ::GetFocus(); m_oChatMessageControl.HideSelection(TRUE, TRUE); m_oChatMessageControl.SetSel(iTotalTextLength, iTotalTextLength); cBuffer2 = m_oChatMessageControl.GetSelText(); LPTSTR...

Ctrl + ; stopped working
For the past week I've been able to enter the current date into a DB sub form field with formatted field using Ctrl = ; but now it's not working properly. Instead of entering the date, it moves the cursor to the center of the formatted field, and inserts nothing. I'm wondering what could have changed. I went directly to the sub form deleted the formatting, then redid it. But it's still not working even there in the sub form alone. My sincere thanks for any help you may offer. -- Norm Shimmel Butler, PA Strange that I should reply to my own message. But I was just surpr...

converting tabular structures in a Word document into an actual table or reading data from the tabular structures using VBA code
I have a macro which can read the last cell/column of all tables in a Word 2003/2007 document and store the data in an MS-Access table. But, some Word documents have the data in structures like a table format but are not actually tables. The structure looks like a table, but the table borders are actually line connectors. These documents were created by a software(VeryPDF PDF to Word converter) which converted the PDF documents(the original format these documents were) into Word documents. 1. Is there a way I can convert/replace the tabular structures with actual tables in Word so t...

Insert,Update Data in sage (MS Access Linked tables) using form
Hi folks, I am developing application using which requires integration with SAGE LINE 50 (Accounting software ) V11... The data which SAGE is using is MC ACCESS 2003 database... with linked tables in it... Now I Have developed the Sage connection using ODBC which works fine when reading the record but cannot Add or Update record into the Linked tables.... When i debug the program the error is at the line where it has... <br> MyodbcCommand.ExecutenonQuery() <br> Can anybody Help ????? -- Message posted via

Yet another duplicate record dilemma
I have a table with records where one field are duplicates. I'm able to query to find duplicates and delete them, however what I need to do is find the duplicates, produce a total from another field, delete the duplicates and update the record field with the new total. Use the Find duplicates wizard, the build an Update query and either add to the field: Update MyTable Inner Join Querty1.ID On MyTable.ID Set MyField = MyField + Query1.MyField or just update it: Update MyTable Inner Join Querty1.ID On MyTable.ID Set MyField = Query1.MyField Then delete the duplicate data. -- Ar... 2008 ContextMenuStrip logical error when running code
Greetings, I have a connectmenustrip item that when clicked runs the following code (see below) Now if the event is called by the button i.e. cmdDeleteingBooking.Click the linq query returns the appropriate value. However when called by cntMnuCancelBookingItem.Click is returns 0 even if a checkbox is of 'TRUE' value. Debugging shows the code runs exactly the same code (which loops around rows in a datagridview checking if the checkbox has been checked). Could someone explain the reasoning why the same code would return different results? Private Sub cmdDelete...

RMS Status Codes
Just wondering if anyone has a list of what the RMS Batch.Status codes 0-15 mean? I can't find them defined anywhere. I'm specifically looking at how to identify Blind Closes so I don't count them in totals until they'e been closed. Thanks! -Zim There is a Knowledge Base Article that covers the different Batch Status codes from 0 - 31. Just search for 'batch status codes' -- Robert Armstrong RMS Systems Inc. "Zim" <> wrote in message news:C72515DB-AD45-4C7D-B8DE-0A18E4A6D0D0@micr...

Excel worksheet with VBE codes don't work elsewhere
Hi, Some of my excel worksheets with embedded controls and VBA codes don' work when I open it on another PC. Is there another way to make i work? Thx -- lazybea ----------------------------------------------------------------------- lazybear's Profile: View this thread: Specifically what problems are you having? Saying "don't work" means absolutely nothing. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC ww...

Filling Web Form
Dear freinds Hello, I have written code in vc++ using MFC to fill the Webform using HTTP post method and I'm able to fill the form but I'm facing a problem that I'm unable to fill login name and password. So any one amongst you have any Idea or help then please help me With Regards Sachin ...

How to make a Add key disabled after adding one record unless
Hi, I have a form where I am adding records. There are two boxes where one has to put the lineitemnumber and another box where one has to put the description. Unless the above two boxes are filled in the Add command box need to be disabled. Now, the problem is after adding one record the Add button is enabled and I cannot disable it. I would appreciate any help to solve this. The error message is: The methos is not supported The following is the code: Private Sub cmdadd_Click() On Error GoTo Err_cmdadd_Click If (IsNull(Me.LineItemID) = True) Or (IsNull(Me.Description) = True) Then ...

Need code snippet to read offline PST file
Hi friends, I have a PST file in my local hard disk and have requirement to read PST file and parse through all folders and then each message item in all folders and then segregate them to different folders based on subject line. Please kindly send the code for the above requirement. Thanks & Regards Ramesh -- ramserp You're going to have to write your own code. Do you know anything about Outlook programming at all? You can start out by looking at information and code samples at -- Ken Slovak [MVP - Outlook] http://www.slo...

Add new record through Form view
I have a table which is linked to a form, i would like to have a command button which will add a new record to my table. On the click of command button it should view the last empty row of my table in a form. On Sat, 26 Dec 2009 11:11:01 -0800, Ranjith Kurian <> wrote: >I have a table which is linked to a form, i would like to have a command >button which will add a new record to my table. >On the click of command button it should view the last empty row of my table >in a form. The Click event should show [Event Proced...

Querying multiple records in two tables
Hi, in my database I have tables for users (UserID, UserName), projects (ProjectID, Project Name), and qualifications (QualID, QualName). I have join tables for users_qualifications (UserID, QualID), and projects_qualifications. (ProjectID, QualID). What I need to do is run a query for a project to show which users have the exact matching qualificiations. Users can have many qualifications, projects can require many qualifications, users may only work on a project if the qualifications required/held match exactly. Please help. Assuming that ProjID, and QualID are numeric, the following sho...

IIS Admin Service Stops Repeatedly
Hi! I am having the same symtoms that are described in knowledge base article The IIS admin and SMP services crashes repeatedly (6 times since last server restart 3 Hours Ago), after IIS crash I receive an instant phone call from my external OWA users!!! I am running Exchange Server 2003 SP1 on Windows Server 2003 R2 and that KB Hotfix does not apply to my OS version. I need help with this PLEASE!!!! The IIS Services simply goes down and theres no clue for me to start troubleshooting. The Exchange Server has been running for 3 months without an...

MS Access 2007, Forms
When using the "Forms Wizard", I need to use the "Style: Ricepaper", but it isn't available in the 2007 version and I have not been successful trying to find it in Office Online or on the web. Does anyone know where I can get it? Access 2007 has 25 AutoFormats, but as you noticed, they are virtually all new ones. It's actually nice to see that these were updated. To get the older Ricepaper style you could probably create a form in an earlier version of Access and then import it into your current database. If you're using the ACCDB file format, you would...

Where can I get a good holiday booking form for my golf business?
I need a quality Booking Form for my Golf Holiday business on the Costa Del Sol. One which includes sections for accommodation, dates, numbers, flight enquiries and car hire enquiries. Any help would be much appreciated on a tight budget. Thanks Dave Wrong forum. Try templates or doing it yourself. :-) -- Russell Dawson Excel Student Please hit "Yes" if this post was helpful. "Dave" wrote: > I need a quality Booking Form for my Golf Holiday business on the Costa Del > Sol. > One which includes sections for accommodation, dates, numbe...

Link to Page when saving to web
Hi, I have some drawings that have several shapes with "Go to page on double-click" behavior. How can I keep this functionality when saving as a web page? Thanks ...

Save Outlook attachments to PC folder automatically
Hi All, I am an absolute newbie to Outlook programming who has been entrusted with the task of figuring out how to get Outlook to dump attachments to emails sent in by certain users to a specified folder on the PC without having to do it manually. I could not get Rules Wizard to do this. Any pointers on how to go about this is really appreciated. Thanks, Rahul Hi, I found the soluton at a website and leave the link for those who might be interested, ..htm Rahul >-----Original Message----- >Hi All, > >I am a...

Won't save office applications, appcrash
Help I cant save documents , excel etc in office 2007 on vista laptop. I have tried open office but this suffers the same problem. Also tried uninstalling and reinstalling office but no change. see below for word report, in excel the fault module was given as PROPSYS.dll Problem Event Name: APPCRASH Application Name: WINWORD.EXE Application Version: 12.0.4518.1014 Application Timestamp: 45428028 Fault Module Name: unknown Fault Module Version: Fault Module Timestamp: 00000000 Exception Code: c0000005 Exception Offset: 00000001 ...

Howto save an edited xml doc w/MSXML
The following script modifies the content of my xml file: --------------------------------------------------------------------------------------------------------------------------------------- Dim nodeSel, nodeVal, index Dim name : name = "//ROOT/first_level/second_level/third_level" Dim xmlfile : xmlfile = "temp.xml" Dim value : value = "false" Dim xDoc Set xDoc = CreateObject( "MSXML.DOMDocument" ) index = 0 If xDoc.Load( xmlfile ) Then Set nodeSel = xDoc.selectSingleNode( name ) 'WScript.Echo "Found node", nodeS...

Closing Excel #2
I have inherited an App desigend by an ex employee Sometimes the program leaves Excel in the task manager The programe uses various routines and calling various functions that define Excel sheets etc (badly named) I'm finding it hard to follow (my 1st experince of .NET) is there a way to KILL any Excel instence when exiting the program. I have come across some posts about GC (garbage collection) like this System.Runtime.InteropServices.Marshal.ReleaseComObject(oXLWsheet) oXLWsheet = Nothing 'System.Runtime.InteropServices.Marshal.ReleaseComObject(oXLWs) oXLWs = Nothing oBook.Clos...

Stop changing of languages in Word 2003 when typing letter.
While typing a letter in Word 2003 it changed from English to what looked like Arabic language. I have rebooted 3 times and started over and still the same occurs. I even copied what I had in English to an email in Yahoo and sent it to myself and rebooted. Came back to that same email and copied it to a new email that I started to myself, and when I started typing it would only type in what looked like Arabic language. This happened to me once a couple of weeks ago, but never occurred again till now. What do I do? In the Language dialog box, turn off the option to autom...

Macro help with saving a spreadsheet with date and time in it
Can someone help me with some code that would save a file name as "schedule-mm-dd-yyyy-hh:mm"? Thanks, Alan Alan, how about something like this Sub Save_As() ActiveWorkbook.SaveAs Filename:="Schedule " & Format(Now, "mm-dd-yyyy-hh-mm") & ".xls", FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False End Sub -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Fee...

stop default website of users pointing to the companyweb
Hi, I just migrated a W2K3 to SBS2008. How can I dissable the pointing all default websites of all users to the http://companyweb? everyone wants to have his own default website. Thanks Olaf Administrative Tools Group Policy Management Windows SBS User Policy User Configuration Windows Settings Internet Explorer Maintenance URLs Important URLs Home Page URL - remove http://companyweb Customise Home Page URL - remove tick Russ -- Russell Grover - SBITS.Biz [SBS-MVP] MCP, MCPS, MCNPS, SBSC Small Business Server/Computer Support - www.SBITS.Biz Question or...