Problem with closing forms

Smee

Well-Known Member
Licensed User
Longtime User
Hi,

I have run into a problem trying to close a form. It does not happen on the desktop just on the device.

if i press the button 'btnCreditCancel' this is in the sub

Sub btnCreditCancel_Click
Credit.Close
End Sub

The name of the form is Credit

The form does not close. i suspect that the program flow is going back to the calling routine and then opening the form again

i put a message box after the calling statement but it gets executed as soon as the form is shown not when the form is closed.

Question 1 how can i find out program flow
Question 2 how can i fix my problem

thanks

Joe

Edit:
i fixed the problem but it does not seem elegant. This is the sub that calls the form and as i suspected it was being executed over and over again. It must get executed as the credit form is closed. So when the calling form is receiving the focus the radio button must be having it's click event fired because it was the last item selected. Is there a way of avoiding this without having to set flags?

Sub trxTypeCard_Click
If CreditFormCalled=True Then
CreditFormCalled=False
Return
End If
CreditCardOk=False
trxType=1
Credit.Show
CreditFormCalled=True
End Sub

Thanks to all and any for some insight!
 
Last edited:

Smee

Well-Known Member
Licensed User
Longtime User
Klaus,

This is calling sub

Sub trxTypeCard_Click
CreditCardOk=False
trxType=1
Credit.Show
End Sub

this is the called form

Sub Credit_Show
Password=""
txtPassword.Text =""
txtCardNo.Text=""
End Sub

Sub btnCreditCancel_Click
Credit.Close
End Sub

Sub Credit_Close
If CreditCardOk=False Then
Msgbox("Credit Denied")
trxType=0
trxTypeCash.Checked=True
end If
End Sub

trxTypeCash is a radio button on the calling form

Hope this helps

Thanks

Joe
 

Smee

Well-Known Member
Licensed User
Longtime User
Thank you for testing Klaus

Yes it works for me too but only on the desktop. The problem occurs only on the device. Didyou test on the device or desktop only?

thanks again

Joe
 

agraham

Expert
Licensed User
Longtime User
I don't think Klaus' code will show the problem as it doesn't have a Credit.Show in trxTypeCard_Click which is probably what the problem is. I have noticed in the past that (.NET and not just Basic4ppc) RadioButtons and CheckBoxes can fire their Click events at unexpected times.
 

klaus

Expert
Licensed User
Longtime User
Top