When I click the "Run Sub/UserForm (F5)" command in the VBA editor I
get a macro list. The code doesn't execute. The "Step Into (F8)"
command doesnt work either. What am I doing wrong?
>On Mar 30, 10:36 am, Matthias Klaey <m...@hotmail.com> wrote:
>> "nuages" <nua...@apex.net.au> wrote:
>> >When I click the "Run Sub/UserForm (F5)" command in the VBA editor I
>> >get a macro list. The code doesn't execute. The "Step Into (F8)"
>> >command doesnt work either. What am I doing wrong?
>>
>> You can only run code directly with F5 if the sub/function does not
>> have any arguments. If the cursor is positioned in a Sub/Function that
>> has arguments, or if the cursor is in the empty space between two
>> procedures, then the macro list pops up. This is the Access standard.
>>
>> If you want to run a Sub/Function that has arguments, you must do so
>> in the immediate window (Ctrl+G):
>>
>> Public MyFunc(intX As Integer) As Integer
>> MyFunc = 2 * intX
>> End Function
>>
>> ? MyFunc(3)
>>
>> 6
>>
>> HTH
>> Matthias Kläy
>> --www.kcc.ch
>
>Thanks very much for quick reply. I now am more aware on how F5, F8
>works. As it happens the the following procedure doesn't have
>arguments and it works properly. But when I try and run it in the
>Editor I still get a Macro list. Any ideas?
>
>Option Compare Database
>Option Explicit
>
>Public Function faq_Open_Correct_Startup_Form()
>'The purpose of this function procedure is to run the
>'following sub procedure at startup.
>sub_Open_Correct_Startup_Form
>End Function
Sorry .. I forgot to mention that F5 only works in standard modules,
not in Form or Report or Class modules. You will have to call these
procedures from the immediate window too, e.g.
Call Forms("MyForm").faq_Open_Correct_Startup_Form
Greetings,
Matthias Kläy
--
www.kcc.ch
get a macro list. The code doesn't execute. The "Step Into (F8)"
command doesnt work either. What am I doing wrong?
>On Mar 30, 10:36 am, Matthias Klaey <m...@hotmail.com> wrote:
>> "nuages" <nua...@apex.net.au> wrote:
>> >When I click the "Run Sub/UserForm (F5)" command in the VBA editor I
>> >get a macro list. The code doesn't execute. The "Step Into (F8)"
>> >command doesnt work either. What am I doing wrong?
>>
>> You can only run code directly with F5 if the sub/function does not
>> have any arguments. If the cursor is positioned in a Sub/Function that
>> has arguments, or if the cursor is in the empty space between two
>> procedures, then the macro list pops up. This is the Access standard.
>>
>> If you want to run a Sub/Function that has arguments, you must do so
>> in the immediate window (Ctrl+G):
>>
>> Public MyFunc(intX As Integer) As Integer
>> MyFunc = 2 * intX
>> End Function
>>
>> ? MyFunc(3)
>>
>> 6
>>
>> HTH
>> Matthias Kläy
>> --www.kcc.ch
>
>Thanks very much for quick reply. I now am more aware on how F5, F8
>works. As it happens the the following procedure doesn't have
>arguments and it works properly. But when I try and run it in the
>Editor I still get a Macro list. Any ideas?
>
>Option Compare Database
>Option Explicit
>
>Public Function faq_Open_Correct_Startup_Form()
>'The purpose of this function procedure is to run the
>'following sub procedure at startup.
>sub_Open_Correct_Startup_Form
>End Function
Sorry .. I forgot to mention that F5 only works in standard modules,
not in Form or Report or Class modules. You will have to call these
procedures from the immediate window too, e.g.
Call Forms("MyForm").faq_Open_Correct_Startup_Form
Greetings,
Matthias Kläy
--
www.kcc.ch
本文探讨了在VBA编辑器中使用F5运行子程序或用户窗体及F8逐步执行时遇到的问题。解释了当子程序含有参数时F5将显示宏列表而非直接执行的原因,并提供了在立即窗口中调用带有参数的函数的方法。
1333

被折叠的 条评论
为什么被折叠?



