Solved

Problems with Generated Forms Unloading and Updating

Posted on 2006-07-16
8
238 Views
Last Modified: 2010-04-30
Problems with Generated Forms

Hey Experts

I have a problem with updating and unloading a generated form the code I use to generate the form is

Dim FrmBillInfo As FrmBillInfo
Set FrmBillInfo = New FrmBillInfo

And the code I use to unload the form is

If Answer = vbYes Then
billtotal = 0
Unload FrmBillInfo
Unload Me
Load frmMain
End If

And the form FrmBillInfo has a listview box and I use the following code to update the listview box

Private Sub GetItems()

Dim Rownumber As Integer

Open App.Path & "\Temp\" & FormID & " " & "Items" For Input As #1

Do While Not EOF(1)

        'Fill in the values from our sequential file...
        Line Input #1, BillPart1
        Line Input #1, BillPart2
        Line Input #1, BillPart3
        Line Input #1, BillPart4
       
        Rownumber = Rownumber + 1
       
        'Now add them in the appropriate place...
        lstBillInfo.ListItems.Add
        lstBillInfo.ListItems.Item(Rownumber).SubItems(1) = BillPart1
        lstBillInfo.ListItems.Item(Rownumber).SubItems(2) = BillPart2
        lstBillInfo.ListItems.Item(Rownumber).SubItems(3) = BillPart3
        lstBillInfo.ListItems.Item(Rownumber).SubItems(4) = BillPart4
       
    Loop

Close #1

But none of the code seems to work the listview box remains blank and the form does not unload when the unload frmBillinfo gets executed and then visual basic crashes when I try to exit my application

Please Help

Nothern_Lights
0
Comment
Question by:Nothern_Lights
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 9

Expert Comment

by:justchat_1
ID: 17117409
This line doesnt trigger an error:
Dim FrmBillInfo As FrmBillInfo

They should have different names...
0
 
LVL 13

Expert Comment

by:iHadi
ID: 17117428
Hi  Nothern_Lights
Addition to what justchat_1 suggested and on the line where you unload the form :

Unload Me
Load frmMain

In this case the form you are trying to unload reloads because there is still code to be executed. Try to switch the lines and make the unload of form the last statement:

Load frmMain
Unload Me
0
 

Author Comment

by:Nothern_Lights
ID: 17117664
Hi I have another problem with lblTotal caption in frmSaleToClientMain is not updating

The code I use to generate the form is

Dim SaleToClientMain As frmSaleToClientMain
Set SaleToClientMain = New frmSaleToClientMain

And the lblTotal.caption gets updated in another form called FrmService which is generated using the code

Dim Service As FrmService
Set Service = New FrmService

and the code to update the lbltotal.caption in frmsaletoclientmain is

frmSaleToClientMain.lblTotal.Caption = lblTotal.Caption

But the caption in frmsaletoclientmain does not update for some reason please help

Nothern_Lights
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:justchat_1
ID: 17117701
this line is incorrect:
frmSaleToClientMain.lblTotal.Caption = lblTotal.Caption

You are setting lbltotak's caption to itself...which form is lblcaption located on and where would you like the caption to come from...
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17117703
* You are setting lbltotal's caption to itself
0
 

Author Comment

by:Nothern_Lights
ID: 17117709
No there is a label called lblTotal in FrmService and another lblTotal in FrmSaletoclientMain

So i thought just copy the text in FrmService to FrmSaleToClientMain by using

frmSaleToClientMain.lblTotal.Caption = lblTotal.Caption

Becuase the code is getting executed in FrmService
 
0
 
LVL 9

Accepted Solution

by:
justchat_1 earned 500 total points
ID: 17117725
thats not what you said before thats why I was confused:
"and the code to update the lbltotal.caption in frmsaletoclientmain is "

try adding a doevents after that line
0
 
LVL 13

Expert Comment

by:iHadi
ID: 17118935
Hi
>>> Dim SaleToClientMain As frmSaleToClientMain

The form instance now is named SaleToClientMain so change the following:
frmSaleToClientMain.lblTotal.Caption = lblTotal.Caption

To:
SaleToClientMain.lblTotal.Caption = lblTotal.Caption
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question