|
-
Jan 19th, 2002, 11:46 PM
#1
Thread Starter
New Member
Saving Filled in Form Files Onto blank Forms.
Hi, What im trying to do is click a command button and have all of the text on the form that has the command button get saved onto another form that looks just like it but is blank with no text.
This is what i have for the save click event so far:
Private Sub cmdSave_Click()
Dim Filenum As Integer
On Error GoTo ErrHandler
Filenum = FreeFile
dlgFile.Filter = "all files(*.*)|*.*|Form Files(*.frm)|*.frm"
dlgFile.FilterIndex = 2
dlgFile.ShowSave
strTheFileName = dlgFile.FileName
Open strTheFileName For Output As #Filenum
Print #Filenum, lstPolicy.Text
Close #Filenum
blnSaved = True
Exit Sub
ErrHandler:
Exit Sub
End Sub
With this code i get a save screen to pop up but when i try to save it nothing happens no information is saved onto a form. Can anyone help me? Does this make any sense at all?
-Flaw
-
Jan 20th, 2002, 12:13 AM
#2
If you're just trying to copy values from one form to another then there are a number of ways you could do it.
One method, (if the controls on the 2nd form have the same name as the ones on the main form), would be to cycle through the controls on the Form and check to see if they exist on the 2nd, if so, populate them with the values on this form, i.e.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim objControl As Control
Load Form2
For Each objControl In Controls
If TypeOf objControl Is TextBox Then
If HasControl(objControl.Name, Form2) Then
Form2.Controls(objControl.Name).Text = objControl.Text
End If
End If
Next
Form2.Show vbModal, Me
End Sub
Private Function HasControl(ByVal sName As String, ByRef Parent As Form) As Boolean
On Error GoTo NoControl
HasControl = Parent.Controls(sName).Name = sName
NoControl:
On Error GoTo 0
End Function
-
Jan 20th, 2002, 01:42 AM
#3
Thread Starter
New Member
Hey thx Aaron for the code, I used it to transfer textbox and label information from my first form to the other one but i cant get it to transfer ListBox information. The property .text didnt work for the ListBox just for the textbox.
For Each objControl2 In Controls
If TypeOf objControl2 Is ListBox Then
If HasControl(objControl2.Name, Form2) Then
Form2.Controls(objControl2.Name).Text = objControl2.Text
End If
End If
Next
Form2.Show vbModal, Me
End Sub
This code doesnt work to transfer the ListBox information over to the form. I dont know, what property or method to use in place of .text for a ListBox?
thx again
-Flaw
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
|