Condition navigating between Controls

I have a form in access 2007, with several controls. I used the On Exit Event 
Procedure for navigating among controls.
Example:
If Method of Payment = “Check” Then
Check No.Set Focus
End If
If Method of Payment = “Credit Card” Then
Credit Card Name.Set Focus
End If
End Sub
And so on for all controls. Form functioned well for months, however today 
went wild. Navigation order does not execute Event Procedure it follows 
exactly the order of TAB ORDER DIALOG BOX.
Please advice
-- 
Bardia
0
Utf
5/13/2010 6:39:01 PM
access 16762 articles. 3 followers. Follow

11 Replies
1149 Views

Similar Articles

[PageSpeed] 56

It sounds like the On Exit event is not firing for some reason. Put these 
two lines of code at the beginning of your On Exit event to test:

MsgBox "On Exit Event Just Fired"
Exit Sub

If you get the message, something else is happening.

Steve
santus@penn.com


"Bardia" <Bardia@discussions.microsoft.com> wrote in message 
news:14F2E84F-B613-45DC-BBD7-8608B134204B@microsoft.com...
>I have a form in access 2007, with several controls. I used the On Exit 
>Event
> Procedure for navigating among controls.
> Example:
> If Method of Payment = "Check" Then
> Check No.Set Focus
> End If
> If Method of Payment = "Credit Card" Then
> Credit Card Name.Set Focus
> End If
> End Sub
> And so on for all controls. Form functioned well for months, however today
> went wild. Navigation order does not execute Event Procedure it follows
> exactly the order of TAB ORDER DIALOG BOX.
> Please advice
> -- 
> Bardia 


0
Steve
5/13/2010 7:12:26 PM
"Bardia" <Bardia@discussions.microsoft.com> wrote in message 
news:14F2E84F-B613-45DC-BBD7-8608B134204B@microsoft.com...
>I have a form in access 2007, with several controls. I used the On Exit 
>Event
> Procedure for navigating among controls.
> Example:
> If Method of Payment = “Check” Then
> Check No.Set Focus
> End If
> If Method of Payment = “Credit Card” Then
> Credit Card Name.Set Focus
> End If
> End Sub
> And so on for all controls. Form functioned well for months, however today
> went wild. Navigation order does not execute Event Procedure it follows
> exactly the order of TAB ORDER DIALOG BOX.
> Please advice


Did you by any chance move the database from a trusted location to an 
untrusted one?  If it looks lie the VBA code is just not executing, the 
database may have become untrusted, and Access 2007 won't execute code in an 
untrusted database.

-- 
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

0
Dirk
5/13/2010 7:23:08 PM
"Bardia" <Bardia@discussions.microsoft.com> wrote in message 
news:14F2E84F-B613-45DC-BBD7-8608B134204B@microsoft.com...
>I have a form in access 2007, with several controls. I used the On Exit 
>Event
> Procedure for navigating among controls.
> Example:
> If Method of Payment = “Check” Then
> Check No.Set Focus
> End If
> If Method of Payment = “Credit Card” Then
> Credit Card Name.Set Focus
> End If
> End Sub
> And so on for all controls. Form functioned well for months, however today
> went wild. Navigation order does not execute Event Procedure it follows
> exactly the order of TAB ORDER DIALOG BOX.
> Please advice
> -- 
> Bardia 

0
Ruben
5/13/2010 7:58:28 PM
Bardia

As I recall, the OnExit event doesn't fire if you click out.

I'm thinking you'll want to try the AfterUpdate event instead.

And if your control name is, literally, "Method of Payment", then you'll 
have to lend Access a hand so it knows what you're talking about.  You'd 
need to delimit that control name with square brackets (e.g., [Method of 
Payment]) because it has embedded spaces.

Good Luck!

Regards

Jeff Boyce
Microsoft Access MVP

-- 
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"Bardia" <Bardia@discussions.microsoft.com> wrote in message 
news:14F2E84F-B613-45DC-BBD7-8608B134204B@microsoft.com...
>I have a form in access 2007, with several controls. I used the On Exit 
>Event
> Procedure for navigating among controls.
> Example:
> If Method of Payment = "Check" Then
> Check No.Set Focus
> End If
> If Method of Payment = "Credit Card" Then
> Credit Card Name.Set Focus
> End If
> End Sub
> And so on for all controls. Form functioned well for months, however today
> went wild. Navigation order does not execute Event Procedure it follows
> exactly the order of TAB ORDER DIALOG BOX.
> Please advice
> -- 
> Bardia 


0
Jeff
5/13/2010 8:15:36 PM
On Thu, 13 May 2010 11:39:01 -0700, Bardia <Bardia@discussions.microsoft.com>
wrote:

>I have a form in access 2007, with several controls. I used the On Exit Event 
>Procedure for navigating among controls.
>Example:
>If Method of Payment = �Check� Then
>Check No.Set Focus
>End If
>If Method of Payment = �Credit Card� Then
>Credit Card Name.Set Focus
>End If
>End Sub
>And so on for all controls. Form functioned well for months, however today 
>went wild. Navigation order does not execute Event Procedure it follows 
>exactly the order of TAB ORDER DIALOG BOX.
>Please advice

In addition to Steve and Dirk's concerns, one problem is that you have blanks
in your control names. Blanks are meaningful in VBA - the line

If Method of Payment = ...

is meaningless to Access, because it sees "Method" as one term, "of" as a
different unrelated term, "Payment" as yet a third. A human can see that it's
all one thing but the poor computer is pretty stupid and literal minded!

Best choice: don't put blanks in the names of things; if the textbox or field
is named MethodOfPayment or Method_Of_Payment you won't have the problem. Note
that SetFocus is one word, not two.

Alternatively, enclose your field/control names in square brackets. I'd also
suggest using the AfterUpdate event (which fires when the user has made a
change) rather than the Exit event (which fires if they just set focus to the
control and leave without doing anything), and use the Me! keyword to refer to
the current form:

If Me![Method of Payment] = �Check� Then
   Me![Check No].SetFocus
ElseIf Me!Method of Payment] = �Credit Card� Then
   Me![Credit Card Name].SetFocus
End If
End Sub

-- 

             John W. Vinson [MVP]
0
John
5/13/2010 8:27:14 PM
Thanks, yes I copied the database file from one computer to another using 
ScanDisk. But on second computer the same Access 2007 is installed. In any 
case if your guess is correct how should I solve this problem?
-- 
Bardia


"Dirk Goldgar" wrote:

> "Bardia" <Bardia@discussions.microsoft.com> wrote in message 
> news:14F2E84F-B613-45DC-BBD7-8608B134204B@microsoft.com...
> >I have a form in access 2007, with several controls. I used the On Exit 
> >Event
> > Procedure for navigating among controls.
> > Example:
> > If Method of Payment = “Check” Then
> > Check No.Set Focus
> > End If
> > If Method of Payment = “Credit Card” Then
> > Credit Card Name.Set Focus
> > End If
> > End Sub
> > And so on for all controls. Form functioned well for months, however today
> > went wild. Navigation order does not execute Event Procedure it follows
> > exactly the order of TAB ORDER DIALOG BOX.
> > Please advice
> 
> 
> Did you by any chance move the database from a trusted location to an 
> untrusted one?  If it looks lie the VBA code is just not executing, the 
> database may have become untrusted, and Access 2007 won't execute code in an 
> untrusted database.
> 
> -- 
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
> 
> (please reply to the newsgroup)
> 
0
Utf
5/14/2010 6:12:08 PM
"Bardia" <Bardia@discussions.microsoft.com> wrote in message 
news:1033A0C1-098A-49F1-821B-44204CED34C7@microsoft.com...
> Thanks, yes I copied the database file from one computer to another using
> ScanDisk. But on second computer the same Access 2007 is installed. In any
> case if your guess is correct how should I solve this problem?

First, in Windows explorer, right-click the database file and choose 
Properties from the popup menu.  It may be that the file has been blocked, 
as having come from another computer.  If so, there will be an Unblock 
button displayed on the property sheet.  If you see that button, click it to 
unblock the file.

If that isn't enough to fix the problem all by itself, then follow the 
instructions in this article to designate the folder containing your 
database as a trusted location:

    http://office.microsoft.com/en-us/help/HA100319991033.aspx
    Create, remove, or change a trusted location for your files

-- 
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

0
Dirk
5/14/2010 6:53:15 PM
Thank you,
Original control names are without any spaces and some are on After update . 
I am really puzzled. This is a very small database and been working well 
since April 2009. Another surprise is that the size of its file was  11,700 
KB, now is only 2,816 KB,  but when I check the total number of records they 
are all there!
I even checked the database options to make sure that the box of Always use 
event procedures is checked. 

-- 
Bardia


"John W. Vinson" wrote:

> On Thu, 13 May 2010 11:39:01 -0700, Bardia <Bardia@discussions.microsoft.com>
> wrote:
> 
> >I have a form in access 2007, with several controls. I used the On Exit Event 
> >Procedure for navigating among controls.
> >Example:
> >If Method of Payment = “Check” Then
> >Check No.Set Focus
> >End If
> >If Method of Payment = “Credit Card” Then
> >Credit Card Name.Set Focus
> >End If
> >End Sub
> >And so on for all controls. Form functioned well for months, however today 
> >went wild. Navigation order does not execute Event Procedure it follows 
> >exactly the order of TAB ORDER DIALOG BOX.
> >Please advice
> 
> In addition to Steve and Dirk's concerns, one problem is that you have blanks
> in your control names. Blanks are meaningful in VBA - the line
> 
> If Method of Payment = ...
> 
> is meaningless to Access, because it sees "Method" as one term, "of" as a
> different unrelated term, "Payment" as yet a third. A human can see that it's
> all one thing but the poor computer is pretty stupid and literal minded!
> 
> Best choice: don't put blanks in the names of things; if the textbox or field
> is named MethodOfPayment or Method_Of_Payment you won't have the problem. Note
> that SetFocus is one word, not two.
> 
> Alternatively, enclose your field/control names in square brackets. I'd also
> suggest using the AfterUpdate event (which fires when the user has made a
> change) rather than the Exit event (which fires if they just set focus to the
> control and leave without doing anything), and use the Me! keyword to refer to
> the current form:
> 
> If Me![Method of Payment] = “Check” Then
>    Me![Check No].SetFocus
> ElseIf Me!Method of Payment] = “Credit Card” Then
>    Me![Credit Card Name].SetFocus
> End If
> End Sub
> 
> -- 
> 
>              John W. Vinson [MVP]
> .
> 
0
Utf
5/14/2010 10:19:01 PM
Thank you,
Original control names are without any spaces and some are on After update . 
I am really puzzled. This is a very small database and been working well 
since April 2009. Another surprise is that the size of its file was  11,700 
KB, now is only 2,816 KB,  but when I check the total number of records they 
are all there!
I even checked the database options to make sure that the box of Always use 
event procedures is checked. 

-- 
Bardia


"Jeff Boyce" wrote:

> Bardia
> 
> As I recall, the OnExit event doesn't fire if you click out.
> 
> I'm thinking you'll want to try the AfterUpdate event instead.
> 
> And if your control name is, literally, "Method of Payment", then you'll 
> have to lend Access a hand so it knows what you're talking about.  You'd 
> need to delimit that control name with square brackets (e.g., [Method of 
> Payment]) because it has embedded spaces.
> 
> Good Luck!
> 
> Regards
> 
> Jeff Boyce
> Microsoft Access MVP
> 
> -- 
> Disclaimer: This author may have received products and services mentioned
> in this post. Mention and/or description of a product or service herein
> does not constitute endorsement thereof.
> 
> Any code or pseudocode included in this post is offered "as is", with no
> guarantee as to suitability.
> 
> You can thank the FTC of the USA for making this disclaimer
> possible/necessary.
> 
> "Bardia" <Bardia@discussions.microsoft.com> wrote in message 
> news:14F2E84F-B613-45DC-BBD7-8608B134204B@microsoft.com...
> >I have a form in access 2007, with several controls. I used the On Exit 
> >Event
> > Procedure for navigating among controls.
> > Example:
> > If Method of Payment = "Check" Then
> > Check No.Set Focus
> > End If
> > If Method of Payment = "Credit Card" Then
> > Credit Card Name.Set Focus
> > End If
> > End Sub
> > And so on for all controls. Form functioned well for months, however today
> > went wild. Navigation order does not execute Event Procedure it follows
> > exactly the order of TAB ORDER DIALOG BOX.
> > Please advice
> > -- 
> > Bardia 
> 
> 
> .
> 
0
Utf
5/14/2010 10:20:01 PM
On Fri, 14 May 2010 15:19:01 -0700, Bardia <Bardia@discussions.microsoft.com>
wrote:

>Thank you,
>Original control names are without any spaces and some are on After update . 
>I am really puzzled. This is a very small database and been working well 
>since April 2009. Another surprise is that the size of its file was  11,700 
>KB, now is only 2,816 KB,  but when I check the total number of records they 
>are all there!
>I even checked the database options to make sure that the box of Always use 
>event procedures is checked. 
>


Hope you have a backup. :-{(

It certainly sounds as if something is corrupt. Is the code you posted in fact
the same as the code actually in use in the database? I cannot see how it
could EVER have worked, at least not as it was posted.
-- 

             John W. Vinson [MVP]
0
John
5/14/2010 10:41:40 PM
I am great full, problem solved. 
-- 
Bardia


"Dirk Goldgar" wrote:

> "Bardia" <Bardia@discussions.microsoft.com> wrote in message 
> news:1033A0C1-098A-49F1-821B-44204CED34C7@microsoft.com...
> > Thanks, yes I copied the database file from one computer to another using
> > ScanDisk. But on second computer the same Access 2007 is installed. In any
> > case if your guess is correct how should I solve this problem?
> 
> First, in Windows explorer, right-click the database file and choose 
> Properties from the popup menu.  It may be that the file has been blocked, 
> as having come from another computer.  If so, there will be an Unblock 
> button displayed on the property sheet.  If you see that button, click it to 
> unblock the file.
> 
> If that isn't enough to fix the problem all by itself, then follow the 
> instructions in this article to designate the folder containing your 
> database as a trusted location:
> 
>     http://office.microsoft.com/en-us/help/HA100319991033.aspx
>     Create, remove, or change a trusted location for your files
> 
> -- 
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
> 
> (please reply to the newsgroup)
> 
0
Utf
5/14/2010 10:56:01 PM
Reply:

Similar Artilces: