473,387 Members | 1,669 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,387 software developers and data experts.

passing form-objects to subroutine

SV
Dear all,

In my application I have a lot of hidden fields. I want to make them invisible
for the users though for debugging reasons I want to make them visible. So I
want to add these objects to an array-variable and pass this variable to a
subroutine in which I make all stored objects in the array-variable invisible.

Can somebody explain me how to declare the correct variables, how to pass these
to a sub routine and how to make these objects invisible ?
This is what i have so far but without any success.

Private Sub Form_load()

dim HiddenFields() as object
HiddenFields(1) = me.TextBox1.name 'one object on the form
MakeUnvisible(HiddenFields) 'passing the array var to the subrouting

Endsub
public sub MakeUnvisible(ByRef Fields as object)
Fields(1).visible = false
end sub

Thanks for any suggestions,

S.V.
Nov 13 '05 #1
3 5508
You may get a different answer to this, but IMHO, there is no need to pass
these objects to your functions (and I assume when you say "fields" that
what you actually mean are textBox controls from your form) . The Forms
collection is accessible at any time through code, so therefore, all of your
controls are accesible. Therefore, this code will work in any module or
form to reference the controls of any open (hidden or visible) form:
Dim formName as String
formName = "MainForm"
Forms(formName).txtCompanyName.visible = False
Forms(formName).lstEmployess.visible = False
formName = "EmployeeForm"
Forms(formName).cboJobTitle.visible = True

or

Forms("PositionForm").txtDuties.visible = False

or even

DoCmd.OpenForm "DataTransferForm"
Dim frm As Form
Set frm = Forms("DataTransferForm")
frm.txtProgressLabel.Caption = "Transferring Data"
Darryl Kerkeslager
"SV" <SV@skynet.be> wrote in message
news:41**********************@news.skynet.be...
Dear all,

In my application I have a lot of hidden fields. I want to make them invisible for the users though for debugging reasons I want to make them visible. So I want to add these objects to an array-variable and pass this variable to a
subroutine in which I make all stored objects in the array-variable invisible.
Can somebody explain me how to declare the correct variables, how to pass these to a sub routine and how to make these objects invisible ?
This is what i have so far but without any success.

Private Sub Form_load()

dim HiddenFields() as object
HiddenFields(1) = me.TextBox1.name 'one object on the form
MakeUnvisible(HiddenFields) 'passing the array var to the subrouting

Endsub
public sub MakeUnvisible(ByRef Fields as object)
Fields(1).visible = false
end sub

Thanks for any suggestions,

S.V.

Nov 13 '05 #2
SV wrote:
Dear all,

In my application I have a lot of hidden fields. I want to make them
invisible for the users though for debugging reasons I want to make them
visible. So I want to add these objects to an array-variable and pass
this variable to a subroutine in which I make all stored objects in the
array-variable invisible.

Can somebody explain me how to declare the correct variables, how to
pass these to a sub routine and how to make these objects invisible ?
This is what i have so far but without any success.

Private Sub Form_load()

dim HiddenFields() as object
HiddenFields(1) = me.TextBox1.name 'one object on the form
MakeUnvisible(HiddenFields) 'passing the array var to the subrouting

Endsub
public sub MakeUnvisible(ByRef Fields as object)
Fields(1).visible = false
end sub

Thanks for any suggestions,

S.V.

Here is an example
Sub PassAr()
'create 6 elements; ar(0)..ar(5)
Dim ar(5) As String
Dim i As Integer
ar(1) = "One"
ar(2) = "Two"
ar(3) = "Three"

'i should be 3
i = GetArCnt(ar())

'display the result...3
MsgBox "There are " & i & " elements"

'call a routine to set textbox one,two,three visible or invisible
SetVisible ar(),Me,True 'set them visible
SetVisible ar(),Me,False 'set them hidden
End Sub
Function GetArCnt(ar() As String) As Integer
Dim s As String
Do While True
'bypass ar(0) by adding 1
If ar(GetArCnt + 1) > "" Then
s = s & ar(GetArCnt + 1)
GetArCnt = GetArCnt + 1

'ex.

Else
'we have a blank row.
Exit Do
End If
Loop
'display string of elements passed
MsgBox s

GetArCnt = GetArCnt
End Function

Sub SetVisible(ar() As String, frm As Form, blnVisible) As Integer
Dim s As String
Do While True
'bypass ar(0) by adding 1
If ar(GetArCnt + 1) > "" Then
s = ar(GetArCnt + 1)
frm(s).Visible = blnVisible
Else
'we have a blank row.
Exit Do
End If
Loop
End Sub
Nov 13 '05 #3
I suggest in the Form_LOAD simply do this:

dim ctl as variant 'access.control
with me
for each ctl in array(.ctl1, .ctl2, ....) 'put your controls here
ctl.visible = DEBUGGING ' put your variable here
next
end with

"SV" <SV@skynet.be> wrote in message
news:41**********************@news.skynet.be...
Dear all,

In my application I have a lot of hidden fields. I want to make them invisible for the users though for debugging reasons I want to make them visible. So I want to add these objects to an array-variable and pass this variable to a
subroutine in which I make all stored objects in the array-variable invisible.
Can somebody explain me how to declare the correct variables, how to pass these to a sub routine and how to make these objects invisible ?
This is what i have so far but without any success.

Private Sub Form_load()

dim HiddenFields() as object
HiddenFields(1) = me.TextBox1.name 'one object on the form
MakeUnvisible(HiddenFields) 'passing the array var to the subrouting

Endsub
public sub MakeUnvisible(ByRef Fields as object)
Fields(1).visible = false
end sub

Thanks for any suggestions,

S.V.

Nov 13 '05 #4

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

Similar topics

5
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page...
1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
2
by: Curtis Justus | last post by:
Hi, I currently have a control that is on a form and I want to pass that exact instance of the control to another form (a child form that appears on a button click). The control has state,...
4
by: Ron Rohrssen | last post by:
I want to show a dialog and when the form (dialog) is closed, return to the calling form. The calling form should then be able to pass the child form to another object with the form as a...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
13
by: Deano | last post by:
Apparently you can only do this with one value i.e Call MyAssetLocationZoom(Me!txtLocation, "Amend data") This runs; Public Sub MyAssetLocationZoom(ctl As Control, formName As String) On...
7
by: AMP | last post by:
Hello, I have this in form1: namespace Pass { public partial class Form1 : Form { public Form2 form2; public Form1() {
0
by: Magnus Bergh | last post by:
I am developing an application for pocketpc and this involvs a but of juggling with different forms. I have an "order entry" type of application. On the main form I have a grid which displays...
5
by: jmartmem | last post by:
Greetings, I have built an Update Record Form in an ASP page. This form contains a number of fields, such as text boxes and menus, to name a few. Upon clicking the 'submit' button, I want the...
4
by: John Sheppard | last post by:
Hello there I was wondering if anyone could help me, I am trying to pass a typed dataset to a dialoged child form by reference. I have binding sources sitting on the child form. So to refresh...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.