Module call problem

N

New_Access

I had following module :

'=====================================
Option Compare Database
Option Explicit

Sub ToggleVisibility(VisibilityStatus As Boolean)
Dim ctlCurr As Control

'focus is set to a control
' that will always be visible before running the loop.

[Specification input_frm].SpeedMode_opt.SetFocus

For Each ctlCurr In [Specification input_frm].Controls
If ctlCurr.Tag = "GroupStep2" Then
ctlCurr.Visible = VisibilityStatus
End If
Next ctlCurr

End Sub
'*****************************************

And then have following code :

==================================
Private Sub SpeedMode_opt_AfterUpdate()
'This code for hide or shown
'fields of speed step 2 specification

On Error GoTo Err_SpeedMode_opt_AfterUpdate

Dim booVisibility As Boolean

booVisibility = Not Me.SpeedMode_opt
Call ToggleVisibility(booVisibility)

End_SpeedMode_opt_AfterUpdate:
Exit Sub

Err_SpeedMode_opt_AfterUpdate:
MsgBox Err.Description & "(" & Err.Number & ") in " & _
Me.Name & ".SpeedMode_opt_AfterUpdate", _
vbOKOnly + vbCritical, "Error Occured"
Resume End_SpeedMode_opt_AfterUpdate
'*****************************************

But then there is an error message
"Object required in Specification input_frm.SpeedMode_opt_AfterUpdate"

And loop doesn't happen.Why?What's wrong? Please help me rid on this.
 
B

boblarson

Try changing this:

For Each ctlCurr In [Specification input_frm].Controls

To this:

For Each ctlCurr In Forms("Specification input_frm").Controls

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________
 
N

New_Access

Bob,Thank's for the reply
but it just can running once only.When I open my form,controls with
specified tag
is invisible.Then I click SpeedMode_opt ( update),the controls with
specified tag
is Visible === OK.But I can't re hide them.Any Idea?
Just for information,SpeedMode_opt is a radio button with two option ( two
value : 1 and 2 )
and excatly what I want is,when SpeedMode_opt value is one the controls with
specified tag is invisible and if the value of SpeedMode_opt is two,it will
be in reverse order.
Thank's


boblarson said:
Try changing this:

For Each ctlCurr In [Specification input_frm].Controls

To this:

For Each ctlCurr In Forms("Specification input_frm").Controls

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


New_Access said:
I had following module :

'=====================================
Option Compare Database
Option Explicit

Sub ToggleVisibility(VisibilityStatus As Boolean)
Dim ctlCurr As Control

'focus is set to a control
' that will always be visible before running the loop.

[Specification input_frm].SpeedMode_opt.SetFocus

For Each ctlCurr In [Specification input_frm].Controls
If ctlCurr.Tag = "GroupStep2" Then
ctlCurr.Visible = VisibilityStatus
End If
Next ctlCurr

End Sub
'*****************************************

And then have following code :

==================================
Private Sub SpeedMode_opt_AfterUpdate()
'This code for hide or shown
'fields of speed step 2 specification

On Error GoTo Err_SpeedMode_opt_AfterUpdate

Dim booVisibility As Boolean

booVisibility = Not Me.SpeedMode_opt
Call ToggleVisibility(booVisibility)

End_SpeedMode_opt_AfterUpdate:
Exit Sub

Err_SpeedMode_opt_AfterUpdate:
MsgBox Err.Description & "(" & Err.Number & ") in " & _
Me.Name & ".SpeedMode_opt_AfterUpdate", _
vbOKOnly + vbCritical, "Error Occured"
Resume End_SpeedMode_opt_AfterUpdate
'*****************************************

But then there is an error message
"Object required in Specification input_frm.SpeedMode_opt_AfterUpdate"

And loop doesn't happen.Why?What's wrong? Please help me rid on this.
 
B

boblarson

You can't set this:

booVisibility = Not Me.SpeedMode_opt

because Me.SpeedMode_opt, according to you, has a value of 1 or 2 and a
boolean has a value of 0 or anything else. So, unless you set booVisibility
to the value of 0 it will always be visible. Not 1 or 2 won't cut it.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


New_Access said:
Bob,Thank's for the reply
but it just can running once only.When I open my form,controls with
specified tag
is invisible.Then I click SpeedMode_opt ( update),the controls with
specified tag
is Visible === OK.But I can't re hide them.Any Idea?
Just for information,SpeedMode_opt is a radio button with two option ( two
value : 1 and 2 )
and excatly what I want is,when SpeedMode_opt value is one the controls with
specified tag is invisible and if the value of SpeedMode_opt is two,it will
be in reverse order.
Thank's


boblarson said:
Try changing this:

For Each ctlCurr In [Specification input_frm].Controls

To this:

For Each ctlCurr In Forms("Specification input_frm").Controls

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


New_Access said:
I had following module :

'=====================================
Option Compare Database
Option Explicit

Sub ToggleVisibility(VisibilityStatus As Boolean)
Dim ctlCurr As Control

'focus is set to a control
' that will always be visible before running the loop.

[Specification input_frm].SpeedMode_opt.SetFocus

For Each ctlCurr In [Specification input_frm].Controls
If ctlCurr.Tag = "GroupStep2" Then
ctlCurr.Visible = VisibilityStatus
End If
Next ctlCurr

End Sub
'*****************************************

And then have following code :

==================================
Private Sub SpeedMode_opt_AfterUpdate()
'This code for hide or shown
'fields of speed step 2 specification

On Error GoTo Err_SpeedMode_opt_AfterUpdate

Dim booVisibility As Boolean

booVisibility = Not Me.SpeedMode_opt
Call ToggleVisibility(booVisibility)

End_SpeedMode_opt_AfterUpdate:
Exit Sub

Err_SpeedMode_opt_AfterUpdate:
MsgBox Err.Description & "(" & Err.Number & ") in " & _
Me.Name & ".SpeedMode_opt_AfterUpdate", _
vbOKOnly + vbCritical, "Error Occured"
Resume End_SpeedMode_opt_AfterUpdate
'*****************************************

But then there is an error message
"Object required in Specification input_frm.SpeedMode_opt_AfterUpdate"

And loop doesn't happen.Why?What's wrong? Please help me rid on this.
 
S

shiro

Thank's Bob,
Now I understand what to do.


boblarson said:
You can't set this:

booVisibility = Not Me.SpeedMode_opt

because Me.SpeedMode_opt, according to you, has a value of 1 or 2 and a
boolean has a value of 0 or anything else. So, unless you set booVisibility
to the value of 0 it will always be visible. Not 1 or 2 won't cut it.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


New_Access said:
Bob,Thank's for the reply
but it just can running once only.When I open my form,controls with
specified tag
is invisible.Then I click SpeedMode_opt ( update),the controls with
specified tag
is Visible === OK.But I can't re hide them.Any Idea?
Just for information,SpeedMode_opt is a radio button with two option two
value : 1 and 2 )
and excatly what I want is,when SpeedMode_opt value is one the controls with
specified tag is invisible and if the value of SpeedMode_opt is two,it will
be in reverse order.
Thank's


boblarson said:
Try changing this:

For Each ctlCurr In [Specification input_frm].Controls

To this:

For Each ctlCurr In Forms("Specification input_frm").Controls

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


:

I had following module :

'=====================================
Option Compare Database
Option Explicit

Sub ToggleVisibility(VisibilityStatus As Boolean)
Dim ctlCurr As Control

'focus is set to a control
' that will always be visible before running the loop.

[Specification input_frm].SpeedMode_opt.SetFocus

For Each ctlCurr In [Specification input_frm].Controls
If ctlCurr.Tag = "GroupStep2" Then
ctlCurr.Visible = VisibilityStatus
End If
Next ctlCurr

End Sub
'*****************************************

And then have following code :

==================================
Private Sub SpeedMode_opt_AfterUpdate()
'This code for hide or shown
'fields of speed step 2 specification

On Error GoTo Err_SpeedMode_opt_AfterUpdate

Dim booVisibility As Boolean

booVisibility = Not Me.SpeedMode_opt
Call ToggleVisibility(booVisibility)

End_SpeedMode_opt_AfterUpdate:
Exit Sub

Err_SpeedMode_opt_AfterUpdate:
MsgBox Err.Description & "(" & Err.Number & ") in " & _
Me.Name & ".SpeedMode_opt_AfterUpdate", _
vbOKOnly + vbCritical, "Error Occured"
Resume End_SpeedMode_opt_AfterUpdate
'*****************************************

But then there is an error message
"Object required in Specification input_frm.SpeedMode_opt_AfterUpdate"

And loop doesn't happen.Why?What's wrong? Please help me rid on this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top