-
Mar 22nd, 2013, 06:51 PM
#1
Thread Starter
Lively Member
[RESOLVED] Working with multiple copies of a form?
I am making a notes app. There is a form, which is the parent, the example, the form that all the new ones are going to be a copy of, and has a textbox in it. It's called frmExample.
I use: dim newNt as new frmExample , to create a new copy of frmExample.
frmExample has a command button(meaning that all the copies will have a command button too) that launches a new form called frmEdit.
In frmEdit, there is a command button. I want that when the user clicks the command button in frmEdit, it will modify the value of the textbox of the form that the first command button has been clicked. So logically it would be: newNt.text1.text = "hello"
But this doesn't work.
So I just want to change the value of the textbox in the form that launched the frmEdit. How can I do this?
I have been around this problem for a long time now, and couldn't find a solution. Thanks.
-
Mar 22nd, 2013, 07:44 PM
#2
Re: Working with multiple copies of a form?
Is this what you want?
vb Code:
Option Explicit Dim frmNT, frm1 As New Form1 Private Sub cmdLaunch_Click() frmNT.cmdLaunch.Caption = "Edit" frmNT.Show frmNT.Text.Visible = False If frmNT.cmdLaunch.Caption = "Edit" Then frm1.Text = "hello" frm1.Show frm1.cmdLaunch.Visible = False Else frm1.Hide End If End Sub Private Sub Form_Load() Set frmNT = Form1 End Sub
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Mar 22nd, 2013, 08:07 PM
#3
Thread Starter
Lively Member
Re: Working with multiple copies of a form?
Actually, not really. I think you misunderstood the question(probably because I didn't explain it very well).
I found this here on vbforums: (http://www.vbforums.com/showthread.p...ces+Form,+How?)
Dim frm As form
Dim i as integer
i=i+1
Set frm = New Form1
frm.Tag = "New_Form_" & i
frm.Show
This solves a huge problem, but it creates another one. How do I unload the form with a specific tag? There is another. Each time I double click that, it uses the code above to create new instancies of frmExample. There is also an integer "i" whose value adds by 1 everytime I double click the other form. So, each frmExample copy's tag is like "New_Form_1" " New_Form_2" "New_Form_3" etc...
But how do I unload, let's say, "New_Form_3" from a command button that is on another form?
-
Mar 23rd, 2013, 03:45 AM
#4
Re: Working with multiple copies of a form?
Originally Posted by kevinKZzaka
How can I do this?
Perhaps the following code snippet might work:
Code:
'In parent Form
Private Sub Command1_Click()
With New frmExample
.Show
End With
End Sub
Code:
'In frmExample
Private Sub Command1_Click()
Set frmEdit.Owner = Me
frmEdit.Show
End Sub
Code:
'In frmEdit
Public Owner As frmExample 'Custom public property
Private Sub Command1_Click()
Owner.Text1 = "hello"
End Sub
Originally Posted by kevinKZzaka
But how do I unload, let's say, "New_Form_3" from a command button that is on another form?
Take advantage of the Forms Collection! Example:
Code:
Private Sub Command2_Click() 'This code assumes there are 4 Forms currently loaded
Unload Forms(3) 'This line unloads the 4th (last) Form
End Sub 'Make sure that the Index < Forms.Count
You can access any property/method of the referenced Form using the dot operator:
Code:
Forms(3).Property
Forms(3).Method
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Mar 23rd, 2013, 08:19 AM
#5
Thread Starter
Lively Member
Re: Working with multiple copies of a form?
Thank you Bonnie West. That was very informative, but I actually solved the problem following the example of another friend similar to this, here on vbforums.
Tags for this Thread
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
|