From: John W. Vinson on 13 May 2010 16:27 On Thu, 13 May 2010 11:39:01 -0700, Bardia <Bardia(a)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]
From: Bardia on 14 May 2010 14:12 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(a)discussions.microsoft.com> wrote in message > news:14F2E84F-B613-45DC-BBD7-8608B134204B(a)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) >
From: Dirk Goldgar on 14 May 2010 14:53 "Bardia" <Bardia(a)discussions.microsoft.com> wrote in message news:1033A0C1-098A-49F1-821B-44204CED34C7(a)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)
From: Bardia on 14 May 2010 18:19 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(a)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] > . >
From: Bardia on 14 May 2010 18:20 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(a)discussions.microsoft.com> wrote in message > news:14F2E84F-B613-45DC-BBD7-8608B134204B(a)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 > > > . >
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: calculate in form Next: Access 2007 Developer Tools and SourceSafe |