473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Passing an argument to a subroutine

What is the proper syntax for sending an argument from a form contol to
a subroutine in a module? For instance, from a textbox on a form I call
a module subroutine from the textbox's OnUpdate event. I want to pass
the form's name to the the Module subroutine. What is the proper syntax
for the textbox event to pass the form name and what is the correct
syntax in the module subroutine to accept the form name as an argument?

Thanks
Scott

Nov 13 '05 #1
3 6748
Not sure of OnUpdate event (AfterUpdate ?), but this is a generic example:

Private Sub Textbox_AfterUpdate()
Call MySub(Me.Name)
End Sub

Public Sub MySub(strFormName As String)
MsgBox "My form name is " & strFormName
End Sub
--

Ken Snell
<MS ACCESS MVP>

"Scott" <sm*********@hdgmansur.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
What is the proper syntax for sending an argument from a form contol to
a subroutine in a module? For instance, from a textbox on a form I call
a module subroutine from the textbox's OnUpdate event. I want to pass
the form's name to the the Module subroutine. What is the proper syntax
for the textbox event to pass the form name and what is the correct
syntax in the module subroutine to accept the form name as an argument?

Thanks
Scott

Nov 13 '05 #2
rkc
Scott wrote:
Thanks. That works well. However, from within the Public Sub, I want to
loop through specific controls (textboxes, comboboxes, etc.). When I do
that using the strfrmName variable I get an error that tells me it can
only loop through a specific entity within a collection. - Presumably
it wants the code to specify Forms!strfrmName. The code loops through
all the text controls to see if they have data before setting the
"Done" button's enabled property to "True." The code is hanging up on
Line (02). I assume it will also choke on Line (10).

Public Sub Check_Controls(strfrmName As String)

Dim ctl As Control
Dim btnStatus As Boolean

Line (01) btnStatus = True
Line (02) For Each ctl In strfrmName
Line (03) If ctl.ControlType <> acCommandButton Or ctl.ControlType <>
acLabel
Line (04) Then
Line (05) If IsEmpty(ctl) Then
Line (06) btnStatus = False
Line (07) End If
Line (08) End If
Line (09) Next ctl

Line (10) strfrmName cmdDone.Enabled = btnStatus

End Sub

Thanks for any help!
Scott


Just pass the form object itself.

Call Check_Controls(Me)

Public Sub Check_Controls(frm As Access.Form)
'---
For Each ctl In frm
'---
End Sub

Lookup the IsEmpty function in the help file.

Nov 13 '05 #3
Thanks. That's it.
Scott

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: slash | last post by:
hi, i am new to perl and am trying to convert the code below into a subroutine but have a problem concering the reading of the input. i am trying to pass an array as an argument to the subroutine....
6
by: Adrian | last post by:
I am trying to pass the address of a C++ function into a Fortran routine to enable the Fortran routine to call this C++ function. I have to do it this way as our build process does not allow...
1
by: Sam | last post by:
Hello all I have a two dimensional array (the dimensions are not known) that needs to be passed to fortran from c++, allocate the dimensions of the array in fortran code, do some filling up of...
7
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a...
3
by: Stephen Travis | last post by:
I'm trying to write a subroutine that will fill an array of some type with several objects of that type. The subroutine works fine if I directly reference the array but if I pass the array as an...
2
by: Mark Drummond | last post by:
Hi all. I've been using Perl for many years now, but I am a "use it and learn it as you need it" type. I having some trouble passing a list to the "search" subroutine from Net::LDAP. I am trying...
3
by: Matt | last post by:
Hi All, I have the current Sub Procedure in a VBA Module. ----------------------------------------------------------------------------------------------------------------------------- Sub...
2
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p *...
1
by: Nathan Sokalski | last post by:
I have finally figured out how to create transparency in GIF files when creating them with VB.NET (it is harder than I think it should be, but at least I can do it now). I would like to write a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.