Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Access Developer" Newsgroups: comp.lang.basic.visual.misc Subject: Re: Newbie question about nested subroutines Date: Thu, 6 Oct 2011 22:49:38 -0500 Lines: 79 Message-ID: <9f7b65F4bbU1@mid.individual.net> References: <4e8df7f8$1@dnews.tpgi.com.au> <9f6jh3FpdsU1@mid.individual.net> <4e8e3cba@dnews.tpgi.com.au> X-Trace: individual.net OmOTBM3dZt9k8hPXM9RoVATtDlId9SNmSparCFMNLMe3bYmLHp Cancel-Lock: sha1:kt7GrTtgnDiWQWIAt/JoueXX2m0= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 X-RFC2646: Format=Flowed; Response Xref: x330-a1.tempe.blueboxinc.net comp.lang.basic.visual.misc:452 Yes, my mistyping. Glad it's "under control now". And, yes, VBA is nearly identical to VB6 code, but the environment in which it runs (MS Office and other apps) is different. -- Larry Linson, Microsoft Office Access MVP Co-author: "Microsoft Access Small Business Solutions", published by Wiley Access newsgroup support is alive and well in USENET comp.databases.ms-access "Dimmer" wrote in message news:4e8e3cba@dnews.tpgi.com.au... > Many thanks, but this is not VBA; it is VB6. I have been given the answer > by Bob (lloks like you are explaining much the same thing, but it is too > abstract for this newbie!. Bob has answered me in terms I can understand. > > Thanks again for responding. > > "Access Developer" wrote in message > news:9f6jh3FpdsU1@mid.individual.net... >> Either I don't understand what you want to do, or (and I suspect this is >> the case) you don't understand programming with VBA. >> >> You can either put that Sub Procedure in the general section of the >> Form's module or in a separate standard Module with a Control object and >> Label object as arguments, and call it from an event of the textbox, >> passing the textbox and label. If you put it in a standard module, you >> can call if from code in multiple Forms' modules. >> >> -- >> Larry Linson, Microsoft Office Access MVP >> Co-author: "Microsoft Access Small Business Solutions", published by >> Wiley >> Access newsgroup support is alive and well in USENET >> comp.databases.ms-access >> >> "Dimmer" wrote in message >> news:4e8df7f8$1@dnews.tpgi.com.au... >>> Hi all >>> >>> I am trying to arrange to access this sub a number of times in a >>> program. >>> >>> The sub works fine in intercepting ESC and certain other keystrokes. >>> >>> I want to somehow arrange to repeatedly use it and this instictively >>> suggests that it should be in a subroutine. But it is already in one! >>> Is there such a thing as nested subroutines? I want to call it and pass >>> to it the particular Textboxes and Label concerned. I emphasise that it >>> works fine but I just don't want to have to have it appearing 13 times >>> in a 13 field form I have designed. >>> >>> Any ideas? >>> >>> Private Sub Text8_KeyPress(KeyAscii As Integer) >>> Label23.Caption = "" '*** this label is used elsewhere for warning >>> messages against that (8 in this case) text field >>> If KeyAscii = 27 Then '*** ESC to blank and step back >>> Text8.Text = "" >>> Text7.SetFocus >>> ElseIf KeyAscii <> 8 Then '***overtype >>> Text8.SelLength = 1 >>> End If >>> Call AlibModule.EnterTabKey(KeyAscii) 'this is a standard routine >>> (Alib is Alan library!) I have developed that treats ENTER and TAB the >>> same. It works fine >>> End Sub >>> >>> >>> The above all works fine. It's just that I want to avoid typing it all >>> out again and again with different values for the LabelNo, TextNo, and >>> PriorTextNo. >>> >> >> > >