Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

Problems with Generated Forms Unloading and Updating

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
Nothern_Lights
Asked:
Nothern_Lights
  • 4
  • 2
  • 2
1 Solution
 
justchat_1Commented:
This line doesnt trigger an error:
Dim FrmBillInfo As FrmBillInfo

They should have different names...
0
 
iHadiCommented:
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
 
Nothern_LightsAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
justchat_1Commented:
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
 
justchat_1Commented:
* You are setting lbltotal's caption to itself
0
 
Nothern_LightsAuthor Commented:
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
 
justchat_1Commented:
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
 
iHadiCommented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now