Select case cmdAction. caption test

Firefly

New Member
Joined
Mar 27, 2002
Messages
16
I'm using a Case cmdAction.caption test against button names on a userform (they change depending on the program showing the form). When it gets to the end of the select, it automatically jumps to the Private Sub UserForm_Terminate() routine to include it in the test (It doesn't include cancel - just terminate), which then incorrectly terminates my macro. Anyone else have this problem & a possible solution? If I take out the Terminate, I can't use the X to close the form without input.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I referenced the code tag section - and have not a clue what it means. (I'm rather new to this stuff.) I don't know if this will help you, but here's the section. A macro assigns the caption on the user form and command buttons depending on the action required. The user form tests the names on the command buttons to determine course of action. It gets through the appropriate case function, but before it finishes with end select it jumps to the User_Form Terminate event. Strange, Huh? Thanks for your help.

Select Case cmdAction.Caption
'Check caption on buttons
'Source program is change a record
Case "OK"
Prog = "EditLot"
Range("aw1").Select
Cells.Find(What:=editname, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False).Activate
dbrow = ActiveCell.Row
Unload Me
'
'Source program is delete a record
Case "Delete"
editname = txtNhood & txtPhase & txtLot & txtBlock
Prog = "DeleteLot"
Range("aw1").Select
Cells.Find(What:=editname, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False).Activate
dbrow = ActiveCell.Row
Unload Me
'
'Source program is display record
Case "Display"
editname = txtNhood & txtPhase & txtLot & txtBlock
Prog = "Showlot"
Range("aw1").Select
Cells.Find(What:=editname, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False).Activate
dbrow = ActiveCell.Row
Unload Me
End Select
Errorhandler:
erchg editname, Prog
Unload Me
End Sub

Private Sub cmdCancel_Click()
Unload Me
progend
End Sub

Private Sub UserForm_Terminate()
Set textBoxes = Nothing
' progend
End Sub
 
Upvote 0
It's going to jump to the terminate event when unload me is called i.e. when one of the conditions is true.

(Terminate is an event which is triggered when the life of the form comes to an end, which is what happens when you close the form with unload me.)

Dave.
 
Upvote 0
On 2002-08-28 07:04, Firefly wrote:
I referenced the code tag section - and have not a clue what it means. (I'm rather new to this stuff.) {snip}
If you saw how your code looked on the message board, I'm sure you'll appreciate why I have no intention of trying to understand it. Hopefully, someone else, more willing to wade through the unformatted code, will help out.
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,704
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top