Расширяясь на том, что должен сказать Mike Powell , я - на самом деле большой поклонник почти всех подкастов в http://www.twit.tv . Большая часть содержания полита вниз немного, но некоторые докладчики являются мыслителями высшего качества - особенно на "На этой неделе в Технологии", ведущая программа.
, О - и Автомобильный Разговор о NPR, но тех парнях почти никогда не входят в SDLC!
Here are some of the different ways you can call things in Microsoft Access:
The sub in the form you are calling MUST be public, as in:
Public Sub DoSomething()
MsgBox "Foo"
End Sub
Call the sub like this:
Call Forms("form1").DoSomething
The form must be open before you make the call.
To call an event procedure, you should call a public procedure within the form, and call the event procedure within this public procedure.
Public Sub DoSomethingElse()
MsgBox "Bar"
End Sub
...just call it directly from your event procedure:
Call DoSomethingElse
If you want, you can actually bind the function to the form control's event without having to create an event procedure under the control. To do this, you first need a public function in the module instead of a sub, like this:
Public Function DoSomethingElse()
MsgBox "Bar"
End Function
Then, if you have a button on the form, instead of putting [Event Procedure] in the OnClick event of the property window, put this:
=DoSomethingElse()
When you click the button, it will call the public function in the module.
If calling a sub looks like this:
Call MySub(MyParameter)
Then calling a function looks like this:
Result=MyFunction(MyFarameter)
where Result is a variable of type returned by the function.
NOTE: You don't always need the Call keyword. Most of the time, you can just call the sub like this:
MySub(MyParameter)
если pptCreator является функцией / процедурой в том же файле, вы можете вызвать ее, как показано ниже
call pptCreator ()
Процедуры в модуле начинают быть полезными и универсальными при передаче аргументов.
Например:
Public Function DoSomethingElse(strMessage As String)
MsgBox strMessage
End Function
Теперь может отображать любое сообщение, которое передается со строковой переменной strMessage.