On Exit Event

On Exit Event

Hello,

I have a form that opens to a new record.  I set the focus to a
control that I want the user to populate without going any further.

This code below will not work, however, because the record has yet to
be created:

Private Sub comSubject_BeforeUpdate(Cancel As Integer)

If IsNull(Me.comSubject) Then
    MsgBox "You cannot leave the [Subject] field empty!"
    Cancel =3D True
    Me.Undo
End If

I suppose I could add a default value or make the record dirty, but
that seems unnecessary.

This code works too well; I can=92t move anywhere until I populate the
control:

Private Sub comSubject_Exit(Cancel As Integer)

'If IsNull(Me.comSubject) Then
'    MsgBox "You cannot leave the [Subject] field empty!"
'    Cancel =3D True
'    Me.Undo
'End If

What I would like to do is not allow the user to continue (like the
exit code example) except if he/she wants to go to another record
(using the navigation buttons at the bottom of the form), essentially
canceling the creation of a new record.

Can I do that?
alex
0
alex
2/19/2010 6:05:53 PM
access 16762 articles. 3 followers. Follow

2 Replies
1705 Views

Similar Articles

[PageSpeed] 43

You can use the enter event of every other editable control on the form like 
this
If IsNull(Me.comSubject) Then
    MsgBox "Fill in the subject first"
    DoCmd.CancelEvent
End If

You may need code to prevent users going back to the subject field and 
making it null after they have filled out other fields.

A different approach:
You could also pop up a form with just one textbox for the subject.
User can't go any further until the fill out the subject.
After they have, you open the main popup with the subject filled in from the 
first popup form.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"alex" <sql_aid@yahoo.com> wrote in message 
news:d37ec5d8-bb6e-4b42-b002-80550af8cacf@j27g2000yqn.googlegroups.com...
On Exit Event

Hello,

I have a form that opens to a new record.  I set the focus to a
control that I want the user to populate without going any further.

This code below will not work, however, because the record has yet to
be created:

Private Sub comSubject_BeforeUpdate(Cancel As Integer)

If IsNull(Me.comSubject) Then
    MsgBox "You cannot leave the [Subject] field empty!"
    Cancel = True
    Me.Undo
End If

I suppose I could add a default value or make the record dirty, but
that seems unnecessary.

This code works too well; I can�t move anywhere until I populate the
control:

Private Sub comSubject_Exit(Cancel As Integer)

'If IsNull(Me.comSubject) Then
'    MsgBox "You cannot leave the [Subject] field empty!"
'    Cancel = True
'    Me.Undo
'End If

What I would like to do is not allow the user to continue (like the
exit code example) except if he/she wants to go to another record
(using the navigation buttons at the bottom of the form), essentially
canceling the creation of a new record.

Can I do that?
alex 


0
Jeanette
2/19/2010 7:21:42 PM
On Feb 19, 2:21=A0pm, "Jeanette Cunningham"
<n...@discussions.microsoft.com> wrote:
> You can use the enter event of every other editable control on the form l=
ike
> this
> If IsNull(Me.comSubject) Then
> =A0 =A0 MsgBox "Fill in the subject first"
> =A0 =A0 DoCmd.CancelEvent
> End If
>
> You may need code to prevent users going back to the subject field and
> making it null after they have filled out other fields.
>
> A different approach:
> You could also pop up a form with just one textbox for the subject.
> User can't go any further until the fill out the subject.
> After they have, you open the main popup with the subject filled in from =
the
> first popup form.
>
> Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>
> "alex" <sql_...@yahoo.com> wrote in message
>
> news:d37ec5d8-bb6e-4b42-b002-80550af8cacf@j27g2000yqn.googlegroups.com...
> On Exit Event
>
> Hello,
>
> I have a form that opens to a new record. =A0I set the focus to a
> control that I want the user to populate without going any further.
>
> This code below will not work, however, because the record has yet to
> be created:
>
> Private Sub comSubject_BeforeUpdate(Cancel As Integer)
>
> If IsNull(Me.comSubject) Then
> =A0 =A0 MsgBox "You cannot leave the [Subject] field empty!"
> =A0 =A0 Cancel =3D True
> =A0 =A0 Me.Undo
> End If
>
> I suppose I could add a default value or make the record dirty, but
> that seems unnecessary.
>
> This code works too well; I can=92t move anywhere until I populate the
> control:
>
> Private Sub comSubject_Exit(Cancel As Integer)
>
> 'If IsNull(Me.comSubject) Then
> ' =A0 =A0MsgBox "You cannot leave the [Subject] field empty!"
> ' =A0 =A0Cancel =3D True
> ' =A0 =A0Me.Undo
> 'End If
>
> What I would like to do is not allow the user to continue (like the
> exit code example) except if he/she wants to go to another record
> (using the navigation buttons at the bottom of the form), essentially
> canceling the creation of a new record.
>
> Can I do that?
> alex

Jeanette, that's a good idea...
and the before update event will take care of the going back and
changing value to null issue.
Thanks,
alex
0
alex
2/19/2010 7:43:18 PM
Reply:

Similar Artilces:

Capture event when a campaign is made a related campaign
Is that possible? Not with a callout anyway. But I'd like to have some custom code executed when that happens. And a pre-post update is not sufficient since a campaign does not have to be saved after one added existing campaigns to it. Thanks a lot -- Nicolas Pagès ...

vCal events
Hi, When I create a calendar event and save it as a vCal event (.vcs file) with outlook, the content type of the resulting file is application/octet-stream. Isn't the content type of a vCal event supposed to be text/x-vCalendar ? Maybe this is an outlook setting that is effecting it ? can someone shed some light on the subject? Thanks, Mike I should not I'm using Outlook 2002 "Mike S" wrote: > Hi, > When I create a calendar event and save it as a vCal event (.vcs file) with > outlook, the content type of the resulting file is application/octet-stream. > I...

Exit versus Exit and Log Off
Anyone know the different between 'Exit' and 'Exit and log off' on Outlook 2000? I'm set up with Exchange account. ...

Outlook 2007 keeps crashing on exit
Everytime I close Outlook 2007 it crashes and then wants to restart. If I cancel the restart Outlook then has to rebuild the data file. Any Ideas how to fix this? Do you have any addins? Are you syncing with a PDA? -- Diane Poremsky [MVP - Outlook] Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/ Outlook Tips by email: dailytips-subscribe-request@lists.outlooktips.net Exchange Messaging Outlook newsletter: EMO-NEWSLETTER-SUBSCRIBE-REQUEST@PEACH.EASE.LSOFT.COM Outlook Tips: http://www.outlook-tips.net/ Outlook &...

Delay on update the mailbox size, OWA event slower on update?
Hi...there is a single win2k3 domain and single Ex2k3 environment, a user reported his mailbox is run out of size, we increated the size a lot. But we wait for another hour, it is still complaining not enough space to send message. Check the System Manager again, the size is way under the limit. How to force the system to update the mailbox size right away when it is increased? Would OWA take longer to update the size? how to force OWA to update as well? Thanks, fshguo. I don't think OWA would be any different. Try this: http://support.microsoft.com/default.aspx?scid=kb;[ln];327378...

Update Event
I have a form called sfrm_status_of_lif2. In this form are two combo boxes, status and sub_by. Third there is a text box, status_dt. Then there is a command button called cmd_notes. When this button is clicked another form opens up called sfrm_status_of_lif_notes. The three boxes appear on this forms header and the data entered from sfrm_status_of_lif2. The problem is if I tab to the cmd_notes button after entering the status, sub_by, and status_dt the info is not in form sfrm_status_of_lif_notes. If I tab off of the form and then click on the cmd_notes button then the selections are ...

powerpoint 2007
When I shutdown my Powerpoint 2007, 95% of the time it does not exit cleanly -- that is, it disappears from the desktop, but there is a POWERPOINT process hanging when checked with "task" tool. Very often, this hanging process runs in the background that consumes quite some CPU, that I have to "kill" it. Wonder what's the problem and how can I fix it? Or this might be a bug to report. This is highly repeatable on my Window XP. I Googled but didn't find similar issues by others. j In article <4cbc2d05-99ee-48de-ac30- 24855a74fdb1@g27g2000yqn.goo...

static build crashes on exit
Greetings. I have a Dialog-based MFC app with multiple CPropertyPages under a tab control. It works great when I have it dynamically linked but it crashes on exit when it's statically linked. The crashing happens in CPropertyPage::Cleanup() on free(m_pOccDialogInfo). I have no idea why this works with a dynamic link but blows up with a static one. I'm just throwing this out there hoping that someone has encountered this before and was successful in fixing it. jorj ...

Mapping fields between entities for Onchange events
We currently have mapping between entities (Account to child Contact) that work if you create the child record directly from the parent record. I would like to see a way to explicitly have fields map between entities after they already exist. This goes from Parent to Child and Child to Parent entities. Example: Child Account up to its Parent Account. If an existing Account is edited to label it as a "Customer" type, then the Account's Parent Account should have it's label changed as well. -- Carroll Little Vis.align, LLC 610-692-3290 x3326 www.visalign.com ---------...

How to log Event in Windows event?
Hi Friends, I want write a simple dialog based application to log events in windows evt file. with a new log node or to standard (Application, Security, System) node. But my timestamp will be different than the local time of computer. how to do this? thanks in anticipation Sachin M Hello Sachin: To do all about logging events in to the windows event logger, you have to read MSDN documentation, about, Logs, Sources, MessageCompiler, .MC files, FormatMesage, etc This article http://www.codeproject.com/system/mctutorial.asp will help you to do all this. Good Luck! "Sachin_M" <...

Event viewer
You nice folks led me to Event Viewer not too long ago, and in studying it, I find under Applications that Automatic Live Update is being run every 3 hours. It isn't my Norton Anti- Virus Live Update, and I do not allow Windows Live Update to run. Or at least I think I have it set so that I run Windows Update when I choose to do so. How can I track down what is running so often, and preventing my system from hibernating as a result? Thank you. can you give me the link to the viewer I need one thanks William B. Lurie wrote: > You nice folks led me to Event Viewer not...

Leave workgroup on Exit
I have setup a workgroup for a small database I built on my companies shared drive. Is there a way once a user exits out of the database, for them to automaticly exit the workgroup and return to their default group? Thanks! If you did not redefine, replace the default mdw system file and simply are calling your mdw as a command line switch when starting the db, then you have no problem, this is already the case. Otherwise, you will have to explain what you have done, how you have set things up currently, so we can try to understand your situation to try and guide you. -- ...

Call function from on exit event
Hi to All the brain boxes helping here, A dilema that I've encountered & have seen others ask the same scenario is: clicking a button which fires the OnExit event of a cbo box does not execute the code of the button (control not transferred at that stage) My question: is it possible to call a function from the OnExit event & the function determines the mouse position/location on the form. If the position/location is within the area of the button then pass back a value (maybe just true or false?) to the sub. That would be handy if trying to make a "Cancel&quo...

Update Chart Titles with Worksheet_Change Event
I have a chart sheet called ("Histogram")with an active X dropdown box which pulls in data from Sheet1. The Active X dropdown list sends a number to a named cell ("ChartNumber") on Sheet1 which is then used within 2 Index formulas to create an active range for my X and Y range to feed my chartsheet("Histogram"). I am trying to update my chart X axis title and my X axis format using a Worksheet_Change Event within Sheet1. I have four basic titles and formats which I have put inside a Case Statement. However I cannot seem to make it work. I want the Worksheet_C...

ActiveX Events / Messages
I am having a dialog box and a activex control on it....I want to handle SCROLL messages for activex I just want to know How can I handle standard scroll events(e.g. WM_HSCROLL) for my activex from my code ?? >From some searching I got I need BEGIN_EVENTSINK_MAP ... END_EVENTSINK_MAP BEGIN_EVENTSINK_MAP() ON_EVENT( <========how to handle standard WM_HSCROLL here ??? END_EVENTSINK_MAP() Do my activex control need to manually fire this standard messages too ? Thanx Ashish ...

event ID: 4153
Hi all, I have this random problem between 2 of my exchange servers, connected through dedicated T1, every once in awhile, i get the message: "exchange1.domain.com attempted to submit without using authentication.The submission was not allowed." Event ID: 4153, Source: MSExchangeIMC, Category: SMTP Interface Events. I couldn't find anything anywhere about this issue. DNS is working fine, and, again, it's random, not happening all the time. PLEASE HELP! ...

Autosave on exit?
Is it possible to have a macro running automatically which will force users of a spreadsheet to save their data before exiting? Or to have a macro which automates the save process on exit? The spreadsheet will be running on Excel 97 and 2000 Cheers Alan ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ Hi Alan In the ThisWorkbook module: Private Sub Workbook_BeforeClose(Cancel As Boolean) ThisWorkbook.Save Cancel = Not (ThisWorkbook.Saved) End Sub -- HTH. Best wishe...

Logon Failure event of a locked out account
I have SBS 2003 SP1. A tech that occasionally works on our server remotely built an account called staff. When he doesn't need to use it I disable the account, lock it out and change the password, but I keep getting this error in groups of two or three. Should I be worried that someone is trying to hack in? Event Type: Failure Audit Event Source: Security Event Category: Logon/Logoff Event ID: 539 Date: 6/25/2010 Time: 8:21:56 AM User: NT AUTHORITY\SYSTEM Computer: SCAPCADC Description: Logon Failure: Reason: Account locked out User Name: staff Domain: ...

Setting up a bi-weekly calendar event
I am trying to create a 12 month calendar at work to post a class that is given every other Friday. Is there a way to formulate this without tying each class in individually. Not sure how you have built your calendar.... Just need to display where the day is equal to the value or the value plus a multiple of 14 (MOD(14)=0 would help here), but ned more info to help any further... "calendar help" wrote: > I am trying to create a 12 month calendar at work to post a class that is > given every other Friday. Is there a way to formulate this without tying &g...

Author of event
On a group calendar, is it possible to find out who made an entry? -- Ferret Mom PK;110394 Wrote: > On a group calendar, is it possible to find out who made an entry? Add the Organizer field to a table view. The Field Chooser will enable you to do that. -- tillman1952 Brian Tillman [MVP-Outlook] http://forums.slipstick.com ...

How to exit from cmdlet
Hello, All I have made specific validation of input parameters in my cmdlet: protected override void BeginProcessing() { if (File.Exists(Output)) { var message = string.Format("File '{0}' already exists. Do you want to remove it?", Output); var result = this.ShouldContinue(message, "File exists"); if (result) { File.Delete(Output); } else { //TODO: Stop cmdlet execution and exit } } // Another validation code } protected override void ProcessRecord() .... And I want to stop cm...

Event ID: 1025 #2
I’ve been seeing this event id (Event ID: 1025) repetitive in our Exchange 2003 servers and can’t fine a Knowledge Base article that can provide me a resolution. Does anyone out there have seeing this Event Id? Would you mind to shear a solution? Thanks Event Type: Warning Event Source: MSExchangeIS Public Store Event Category: General Event ID: 1025 Date: 5/31/2006 Time: 7:13:54 AM User: N/A Computer: ESD1MXOLYMB02 Description: An error occurred on database "Expanded Stores Storage Group\Public Information Store (MB02)". Function name or description of problem: EcSubfolde...

Event Log
I am tring to write to a custom event log on a Web Server from a Web Service on the same machine. Here is my code: // Create the source, if it does not already exist. if(!EventLog.SourceExists(sAppName)) { EventLog.CreateEventSource(sAppName, sLogName, sMachineName); } I am currently running on my localhost. I get an error when I check so see if the custom event log exists. The error I get is: Requested registry access is not allowed. Can this be done, and if so, what am I doing wrong? Thanks, Robert -- Robert Hill...

Every 5 seconds an error (connection SharePoint) in Event Viewer
I have something strange in the Event Viewer on my MS Project Server. Every 5 seconds I have an error coming from the source Windows SharePoint Server: Source: Windows SharePoint Server Description: #50070 (the error is in Dutch b'cause it's a Dutch installation of MS Project server): cannot connect database WSSConfigDB on servername. Check the database connection and check if the database server is active. I restarted the server, but the error keeps coming every 5 seconds. The database is running (MS Project runs on the same machine). How can I get rid of this annoying...

Journal no longer records events
My Outlook 98 Journal has been recording Word and Excel events for years and suddenly it has stopped. I may have inadvertently put in a rule, but I cant find anything. Any suggestions would be appreciated. ...