Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exit event doesn't run correctly

Status
Not open for further replies.

nkamp1

Programmer
Sep 20, 2004
5
NL
Hello,

I have a one column combobox. If I leave this combobox the exit event runs correctly,

I have also a two column combobox, and if I leave this combobox the exit event doesn't fire.

I don't understand why. I suppose that it has something todo with the two colomn but I don't know why. Does somebody else have a idea?
 
what is your code you are using, if you could post it that would be of help.
 
Here is my code:

THE FIRST EVENT SINGLE COLUMN WHICH WORKS:

Private Sub cmbStatNaamMSRStat1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

If (ufmain.cmbStatCodeMSRStat1.Value = "?") Then

' Om te voorkomen dat de het object de focus verliest wordt het cancel argument binnen het Exit event
' de waarde TRUE toegekend!
Cancel = True

ufmain.cmbStatNaamMSRStat1.SetFocus
ufmain.cmbStatNaamMSRStat2.Enabled = False
ufmain.btnAddSubnet.Enabled = False
ufmain.btnChangeSubnet.Enabled = False

ufmain.MultiPage1.pgSubstat.Enabled = False
ufmain.MultiPage1.pgstatlist.Enabled = False
ufmain.MultiPage1.pgTools.Enabled = False
ufmain.MultiPage1.pgSystem.Enabled = False
ufmain.MultiPage1.pgTest.Enabled = False

MsgBox "De stationsnaam is in de stationslijst onbekend, hierdoor kan niet de bijbehorende stationscode" & _
Chr(10) & Chr(13) & "in de stationslijst worden gevonden." & _
Chr(10) & Chr(13) & _
Chr(10) & Chr(13) & " Corrigeer de stationsnaam"

' Cancel is getting the value False because if the user choose not a correct value in the combobox and he is
' closing the application, the application will crash because there is not focus on it.
Cancel = False
End If
End Sub


THE SECOND ONE MULTICOLUMN WHICH DOESN'T WORK:

Private Sub cmbStatNaamMSRStat2_Exit(ByVal Cancel As MSForms.ReturnBoolean)

If (ufmain.cmbStatCodeMSRStat2.Value = "?") Then

' Om te voorkomen dat de het object de focus verliest wordt het cancel argument binnen het Exit event
' de waarde TRUE toegekend!
Cancel = True

ufmain.cmbStatNaamMSRStat2.SetFocus
ufmain.cmbStatNaamMSRStat1.Enabled = False
ufmain.btnAddSubnet.Enabled = False
ufmain.btnChangeSubnet.Enabled = False

ufmain.MultiPage1.pgSubstat.Enabled = False
ufmain.MultiPage1.pgstatlist.Enabled = False
ufmain.MultiPage1.pgTools.Enabled = False
ufmain.MultiPage1.pgSystem.Enabled = False
ufmain.MultiPage1.pgTest.Enabled = False

MsgBox "De stationsnaam is in de stationslijst onbekend, hierdoor kan niet de bijbehorende stationscode" & _
Chr(10) & Chr(13) & "in de stationslijst worden gevonden." & _
Chr(10) & Chr(13) & _
Chr(10) & Chr(13) & " Corrigeer de stationsnaam"

' De waarde van Cancel krijgt de waarde False, aangezien anders de focus hierop blijft staan, wat als
' consequentie heeft dat indien de gebruiker de applicatie afsluit deze crasht omdat er geen focus
' op het "kruisje" gezet kan worden.
Cancel = False
End If
End Sub
 
Hello,

I've found my problem but not the solution. Both comboboxes are placed in different frames. The one which is working there are in the same frame two radio buttons enabled. In the other frame is nothing enabled except this combobox.

I was expecting that the focus was going outside frame because I have two buttons which are enabled on these form.

But what is the solution. To put a extra object in this frame is not a right solution in my opinion.

What I still not understand why the setfocus is not working?

Nico.
 
one thing that you could try is changing: -

If (ufmain.cmbStatCodeMSRStat2.Value = "?") Then
to

If (ufmain.cmbStatCodeMSRStat2.column(0).vlaue = "?") Then

Would you be better using the After_Update procedure instead???

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top