Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 18th, 2003, 05:50 PM
Authorized User
 
Join Date: Nov 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MrDannyP
Default MDI Forms. 2 Issues

Just learnt about this one but Ive come across two problems which turn out to be significant problems if I cant get anyone to help me sort them out.

I use the following code to create a new form using a template I have already designed:

[vb]Private Sub mnuFileNew_Click()

Static Counter As Integer
Dim frm As New frmREG
Counter = Counter + 1
frm.Caption = "MDI Child" & Counter
frm.Show

End Sub[/vb]

Only problem is, when I close the application, all forms are not there. Is there any way to save all the new forms created unless told to be deleted by the user ?

The Second problem is I cant seem to use the database I created. I used Data Manager to create a type of record sheet.

Everytime I click the 'Play' button to start my application I get:

[vb]Compile Error:

User-defined not defined[/vb]

And the following piece of code is highlighted:

[vb]Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset[/vb]

Any ideas ?

Thankyou for looking.

Im new.  Please be gentle :)
__________________
Im new.  Please be gentle :)
 
Old November 19th, 2003, 04:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Dynamically created forms are not persisted between sessions. You'll have to code it yourself to save whatever details you need to re-create the form. Then read your saved data and re-create the forms when the app starts next time.

Re your 2nd prob - do you have a ref to ADO in the Project > References?
 
Old November 19th, 2003, 05:05 PM
Authorized User
 
Join Date: Nov 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MrDannyP
Default

do you have a ref to ADO in the Project > References?

Eerrm. Im new to visual basic so can you give me a little hint, perhaps an example or a webiste with an example.

Thankyou

Im new.  Please be gentle :)
 
Old November 19th, 2003, 05:44 PM
Authorized User
 
Join Date: Nov 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MrDannyP
Default

Soz about the last message, ignore that. Just found it under Microsoft.

That helped alot thanx.

Only problem is to save all the individual forms. Surely I cant be the only person out there that is having this problem

Im new.  Please be gentle :)
 
Old November 20th, 2003, 03:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Just curious but why do you need to save an actual form? What is it about the form that needs saving? Is it the data it contains, or maybe the layout, or something else?

If you could explain what you're trying to achieve it would help I think.

rgds
Phil
 
Old November 20th, 2003, 04:15 PM
Authorized User
 
Join Date: Nov 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MrDannyP
Default

OK I use data management to create a record sheet. All information is saved into a database.

For my project I want to create a new form which has a picture of a car on it so I know what information goes with each car.

I would like the form to be saved so I dont have to keep adding new forms.

I have made the template I want, its just the code to save the forms I cant work out and to be honest I dont know where to start.

So if anyone can help me I would be greatful.

Thankyou for looking.

Im new.  Please be gentle :)
 
Old November 21st, 2003, 04:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:OK I use data management to create a record sheet.
This means nothing to me.

If the information you wnat to display on these forms is in the database, why can't you just re-create the forms from the database info when the app loads?
 
Old November 21st, 2003, 05:30 AM
Authorized User
 
Join Date: Nov 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MrDannyP
Default

OK perhaps I havent made myself clear.

I have one form that keeps every piece of information entered about each job.

When I click 'Add', a new form will be created and the caption will be the name of the REG.

On this new form there are different stages of a workshop:

Stripping, Panel, Paint, Fitting & Valeting.

I am using picture boxes, one under each of those headings with an image of a car in. When you press on the picture box, it moves under then next heading. In theory, keeping track of where the car is.

I want to be able to save the form when its 1st created so the next time the app is opened, the form is still there and I can carry on with work on the car. This will save loads of time if it is saved, otherwise, each time the app is opened, I will have to create each form again and place the image under the correct heading.

So just to keep it short, I have made a template of a form I want to use, all I would like to do, is to be able to save the form as soon as it is created.

Im new.  Please be gentle :)
 
Old November 21st, 2003, 05:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:
This will save loads of time if it is saved, otherwise, each time the app is opened, I will have to create each form again and place the image under the correct heading.
But that is exactly what you have to do. As I said before there is no automatic way of saving a dynamically created form, so you have to code it yourself.
 
Old November 21st, 2003, 06:15 PM
Authorized User
 
Join Date: Nov 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MrDannyP
Default

OK I am using the following code to save the contents from 2 text boxes into one .txt file:


 Private Sub cmdSave_Click()

On Error GoTo ErrHandler
CommonDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt|*.txt|Batch files (*.bat)|*.bat"
CommonDialog1.FilterIndex = 2
CommonDialog1.ShowSave
Filename = CommonDialog1.Filename
F = FreeFile
Open Filename For Output As #F
Print #F, Text1.Text
Print #F, Text2.Text
Close #F
ErrHandler:

End Sub


This saves each of the text entered in each text box, each on their own line.

I only have one problem now. I use the following code to load the file into the text boxes:


 Private Sub cmdLoad_Click()

On Error GoTo ErrHandler
CommonDialog1.Filter = "All Files (*.*)|*.*|Text Files(*.txt)|*.txt|Batch files (*.bat)|*.bat"
CommonDialog1.FilterIndex = 2
CommonDialog1.ShowOpen
Filename = CommonDialog1.Filename
F = FreeFile
Open Filename For Input As #F
Text1.Text = Input$(LOF(F), F)
Text2.Text = Input$(LOF(F), F)
Close #F
ErrHandler:

End Sub


Only problem is that it places all the information into the 1st text box only and doesnt place the correct piece of text into the corresponding text boxes.

Any ideas ?

Im new.  Please be gentle :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
MDI & MDI Child Forms Menu's in VB2005 yulyos Visual Studio 2005 0 September 7th, 2007 09:49 AM
MDI Forms Gustav_Haglund VB How-To 8 December 8th, 2005 07:05 PM
MDI Forms kobystud C# 0 June 7th, 2004 04:14 AM
MDI Forms tim33_909 VB.NET 2002/2003 Basics 1 November 17th, 2003 03:42 PM
MDI Forms? aldwincusi VB How-To 1 September 11th, 2003 04:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.