473,698 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6777
Not sure of OnUpdate event (AfterUpdate ?), but this is a generic example:

Private Sub Textbox_AfterUp date()
Call MySub(Me.Name)
End Sub

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

Ken Snell
<MS ACCESS MVP>

"Scott" <sm*********@hd gmansur.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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!strfrmNam e. 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
8890
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. the array is produced earlier in the program and needs to be passed to the subroutine. @array holds LINES of words separated by whitespace. so, $array will be one line from the DATA below. the code below runs fine as a separate program but I...
6
3525
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 circular dependencies of DLL's. Does anyone know how to do this, I have tried everything in my book. I have a C++ function GetP: DllExport void GetP()
1
6429
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 the array in fortran and then accessing it in my c++ code. Say in my c++ code I have; extern "C" { void foo_(float **, int &, int &); }
7
9562
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 subroutine Let's say theres a sub that creates buttons and I want it to receive as a parameter the address of the sub that handles the OnClick event for the button being created How do I pass such a parameter Thanks in advance Richar
3
2540
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 Object, it throws a cast error. The only way I've been able to get this to work is to return an ArrayList and then use the .CopyTo method of the ArrayList to stuff the ArrayList into my array. I've tried DirectCast and several other methods to get...
2
4730
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 to pass a list of attributes to be returned by search. The basic method call is: my $searchresults = $ldap->search(OPTIONS) One of the options is "attrs =>" which the documentation describes as "A
3
4122
by: Matt | last post by:
Hi All, I have the current Sub Procedure in a VBA Module. ----------------------------------------------------------------------------------------------------------------------------- Sub openForm(formName As String, Optional varToSend As Object) If varToSend Is Missing Then DoCmd.openForm formName Else DoCmd.openForm formName, , , , , , varToSend
2
4432
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 * len(id) # id is a list of strings Id_dat=StringVector() for i in range(len(Id)): ....Id_dat=id
1
1187
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 couple functions and/or subroutines to make this easier. However, when I pass a Bitmap as a parameter it does not include the data from the Palette property. I have also tried passing the Palette as a separate argument, but the same problem...
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8905
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7743
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.