|
-
Jan 26th, 2000, 01:11 AM
#1
Thread Starter
Member
Suppose I Dim GetName As String and want to pass that variable to another form. The variable is being retrieved from a database. Now I need to pass it to another form and use it in various ways within that form. Any suggestions?
[This message has been edited by mecca (edited 01-26-2000).]
-
Jan 26th, 2000, 01:12 AM
#2
Hyperactive Member
in your second form:
dim strVariable as string
strVariable = form1!GetName
-
Jan 26th, 2000, 01:36 AM
#3
In order for netSurfer's suggestion to work, GetName needs to be defined as Public in Form1's Declarations area. You will also need to change the exlamation point to a period in the code.
'In Form1
Public GetName As String
'In Form2
Dim strVariable As String
strVariable = form1!GetName
------------------
Marty
Why is it called lipstick if you can still move your lips?
-
Jan 26th, 2000, 01:37 AM
#4
Hyperactive Member
Martin, you're right, that's what happens when I'm doing 4 things at once. Thanks for catching that.
-
Jan 26th, 2000, 01:45 AM
#5
Thread Starter
Member
Neither worked. I get this error "Control GetName not found!" Any suggestions?
-
Jan 26th, 2000, 01:50 AM
#6
Hyperactive Member
strVariable = form1!GetName
change to:
strVariable = form1.GetName
-
Jan 26th, 2000, 01:57 AM
#7
Thread Starter
Member
Great! Thanks. Appreciate the help!
-
Jan 26th, 2000, 02:01 AM
#8
You can also do what you want by creating a new Property for Form1. In the example below I changed your GetName to MyName. I would have used "Name", but of course every form already has a "Name" property.
Code:
' In Form1
Option Explicit
Private m_Name As String
Private Sub Form_Load()
MyName = "Marty"
Form2.Show
End Sub
Public Property Get MyName() As String
MyName = m_Name
End Property
Public Property Let MyName(ByVal sName As String)
m_Name = sName
End Property
'=====================================
' In Form2
Private Sub Command1_Click()
MsgBox Form1.MyName
End Sub
------------------
Marty
Why is it called lipstick if you can still move your lips?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|