New problem

This is probably an easy thing… I have a pretty simple application, two forms/windows, and that’s it. The primary form is for data entry. The second form is for review. Now the second form I don’t want it to open if there is nothing to review. So I set it up to check for valid records, if there is nothing, then close the review and re-open the main… but that isn’t quite working as I planned….

This is code from the main form:

// NONEYA Stand-Alone Meter Reading Application
// Ian McDonald Driver ID: XXXXXXXX
// Started 13 Jun 2024 @ 16:30
// This is my intellectual property

// Variables defined here…

’ – == None == –

// The code that does stuff…
frmReadReview.Show
frmReadMeters.Close

This is code from the second form:

// NONEYA Stand-Alone Meter Reading Application
// Ian McDonald Driver ID: XXXXXXX
// Started 13 Jun 2024 @ 16:30
// This is my intellectual property

// Variables defined here…
Var rsData As RowSet = dbMeters.SelectSQL( “SELECT * FROM tblPreviousReads WHERE statusOf=? ORDER BY rNum ASC”, “A” )

// The code that does stuff…
If( rsData.Column( “rNum” ).StringValue = “” ) Then
MessageBox( “There are currently no records ready for review. Good-bye!” )
frmReadReview.Close
frmReadMeters.Show
Else
lblRnum.Text = rsData.Column( “rNum” ).StringValue

If( rsData.Column( “unitTank” ).StringValue = “Tank” ) Then
txtAddress.Text = rsData.Column( “address” ).StringValue
lblMerSerNum.Text = “Tank Ser #”
ElseIf( rsData.Column( “unitTank” ).StringValue = “” ) Then
txtAddress.Text = rsData.Column( “address” ).StringValue
lblMerSerNum.Text = “Meter Ser #”
Else
txtAddress.Text = rsData.Column( “address” ).StringValue
lblMerSerNum.Text = “Meter Ser #”
End If

txtCurrRead.Text = rsData.Column( “currRead” ).StringValue
txtCustNum.Text = rsData.Column( “acctNum” ).StringValue
txtLastRead.Text = rsData.Column( “lastRead” ).StringValue
txtLastReadDate.Text = rsData.Column( “readDate” ).StringValue
txtMetSerNum.Text = rsData.Column( “unitSerNum” ).StringValue
txtNotes.Text = rsData.Column( “notes” ).StringValue
txtOff.SetFocus

frmReadReview.mthSourceTest( )

Var rsCnt As RowSet = dbMeters.SelectSQL( “SELECT * FROM tblPreviousReads WHERE statusOf=?”, “A” )
Var iRecCnt As Integer = rsCnt.RowCount

lblRecCntr.Text = "1 Of " + iRecCnt.ToString
End If

The problem is the main form never reappears/opens….

Maybe you should’nt close the Window which will open the other Window, before the other Window isn’t shown? (Read: “Maybe, reverse the above order?”)

BTW: Can you please change the title of your Thread to something meaningfull? :wink:

3 Likes

Can you create a simple sample project that shows the problem?
You can zip it and upload to your post.

1 Like

What if you use .Hide instead of .Close?

Because the first line is not showMODAL, the second line executes after frmReadMeters has been shown. So it appears and immediately gets closed.

Reversing the order should sort it, as Sascha says

There are better ways to handle this, but that should do it.

1 Like