Thanks Peter, it works, it was my bad.
"Peter N. Kipe"
<pkipe@c... To: "professional vb" <pro_vb@p...>
.com> cc:
Subject: [pro_vb] RE: Help with global procedure
02/06/2003 11:39
AM
Please respond to
"professional vb"
It works for me, except that I had to change the statement in mCheck from
.Enable to .Enabled -- I don't think I checked my original suggestion for
syntax errors.
I just created a new project, and in Form1 I put a frame, two indexed
checkboxes in the frame, and a command button. I let all names default. I
set the .Enabled property of Command1 to False. In the code page, I put
the
following:
Option Explicit
Private Sub Check1_Click(Index As Integer)
Call mCheck(Index, Me)
End Sub
I then added a new form (Form2), and made it identical to Form1.
I then added a module, and inserted the following code:
Option Explicit
Public Sub mCheck(ByVal Index As Integer, ByVal aForm As Form)
Dim lForm As Form
Set lForm = aForm
lForm.Command1.Enabled = True
lForm.Frame1.Width = 4500
End Sub
When I ran the project, Form1 appeared. When I checked a checkbox, the
frame size changed, and the command button became enabled.
Pete
-----Original Message-----
From: jleung@m... [mailto:jleung@m...]
Sent: Thursday, February 06, 2003 12:24 PM
To: professional vb
Subject: [pro_vb] RE: Help with global procedure
Thanks for the reply, Pete.
'In Module
Public Sub mCheck(ByVal Index As Integer, ByVal aForm As Form)
Dim lForm As Form
Set lForm = aForm
lForm.cmdSave.Enable = True
lForm.Frame1.Width = 5775
End Sub
The above procedure doesn't work, I got the following error:
Run-time error '438':
Object doesn't support this property or method
But I know for sure this will work:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'In Form1
'Check1 is an array
Private Sub Check1_Click(Index As Integer)
Call mCheck(Index)
End Sub
'In Module
Public Sub mCheck(ByVal Index As Integer)
Form1.cmdSave.Enabled = True
Form1.Frame1.Width = 5775
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Any thought on how to pass the form to global module?
J
"Peter N. Kipe"
<pkipe@c... To: "professional vb"
<pro_vb@p...>
.com> cc:
Subject: [pro_vb] RE: Help
with global procedure
02/06/2003 09:19
AM
Please respond to
"professional vb"
Try this -- I haven't tested it, but it should work. I removed the pieces
that didn't relate directly to what was being done in the public sub.
Pete
-----Original Message-----
From: jleung@m... [mailto:jleung@m...]
Sent: Thursday, February 06, 2003 10:05 AM
To: professional vb
Subject: [pro_vb] Help with global procedure
Dear all,
Can anyone tell me how to make the following work? I'm trying to use a
global procedure for 2 forms' controls, both forms that have (almost)
indentical controls.
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
'In Form1
'Check1 is an array
Private Sub Check1_Click(Index As Integer)
Call mCheck(Index, Me)
End Sub
'In Form2
'Check1 is an array
Private Sub Check1_Click(Index As Integer)
Call mCheck(Index, Me)
End Sub
'In Module
Public Sub mCheck(ByVal Index As Integer, ByVal aForm As Form)
Dim lForm As Form
Set lForm = aForm
lForm.cmdSave.Enable = True
lForm.Frame1.Width = 5775
End Sub
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
Thanks in advance,
Jason