ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combobox_change event problem (https://www.excelbanter.com/excel-programming/337565-combobox_change-event-problem.html)

Shawn G.[_2_]

Combobox_change event problem
 
I have a form that uses a combobox to fill in the textboxes on the form to be
edited using the change event. Work great but when the text boxes are all
edited and the user press the OK button to copy the fields to the worksheet
as soon as it gets to the first
..cells(4, 1).Value = frmEditText.txtbxName.Value
It immediatley goes to the combobox_change event, which resets the form.
Any way around this or a way to turn off the combobox_change event
temporarily while the code fills in the proper cells?????

sebastienm

Combobox_change event problem
 
Hi,
You could use a variable to track whether the event should be processed or
not:
'form level variable
Private ProcessingOk as boolean

'in your CmdOk_Click sub, set processingOk
Sub CmdOk_Click( )
ProcessingOk=True
' ... processing code here
ProcessingOk = False
End Sub

'in your other controls event subs, process only if Not OrocessingOk.
'Eg
Sub combobox_change ( )
If Not ProcessingOk Then
'your regular code here
End if
End Sub

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Shawn G." wrote:

I have a form that uses a combobox to fill in the textboxes on the form to be
edited using the change event. Work great but when the text boxes are all
edited and the user press the OK button to copy the fields to the worksheet
as soon as it gets to the first
.cells(4, 1).Value = frmEditText.txtbxName.Value
It immediatley goes to the combobox_change event, which resets the form.
Any way around this or a way to turn off the combobox_change event
temporarily while the code fills in the proper cells?????


Shawn G.

Combobox_change event problem
 
Thank you, I hadn't thought of that!!! Worked great!

"sebastienm" wrote:

Hi,
You could use a variable to track whether the event should be processed or
not:
'form level variable
Private ProcessingOk as boolean

'in your CmdOk_Click sub, set processingOk
Sub CmdOk_Click( )
ProcessingOk=True
' ... processing code here
ProcessingOk = False
End Sub

'in your other controls event subs, process only if Not OrocessingOk.
'Eg
Sub combobox_change ( )
If Not ProcessingOk Then
'your regular code here
End if
End Sub

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Shawn G." wrote:

I have a form that uses a combobox to fill in the textboxes on the form to be
edited using the change event. Work great but when the text boxes are all
edited and the user press the OK button to copy the fields to the worksheet
as soon as it gets to the first
.cells(4, 1).Value = frmEditText.txtbxName.Value
It immediatley goes to the combobox_change event, which resets the form.
Any way around this or a way to turn off the combobox_change event
temporarily while the code fills in the proper cells?????



All times are GMT +1. The time now is 02:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com