Solved

Problems with Generated Forms Unloading and Updating

Posted on 2006-07-16
8
188 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
  • 4
  • 2
  • 2
8 Comments
 
LVL 9

Expert Comment

by:justchat_1
Comment Utility
This line doesnt trigger an error:
Dim FrmBillInfo As FrmBillInfo

They should have different names...
0
 
LVL 13

Expert Comment

by:iHadi
Comment Utility
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
Comment Utility
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
 
LVL 9

Expert Comment

by:justchat_1
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 9

Expert Comment

by:justchat_1
Comment Utility
* You are setting lbltotal's caption to itself
0
 

Author Comment

by:Nothern_Lights
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now