Solved

Problems with Generated Forms Unloading and Updating

Posted on 2006-07-16
8
203 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

910 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

24 Experts available now in Live!

Get 1:1 Help Now