467,080 Members | 957 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,080 developers. It's quick & easy.

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
  • viewed: 4748
Share:
3 Replies
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Paul | last post: by
1 post views Thread by Paul | last post: by
2 posts views Thread by Curtis Justus | last post: by
4 posts views Thread by Ron Rohrssen | last post: by
reply views Thread by Magnus Bergh | last post: by
4 posts views Thread by John Sheppard | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.