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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text Box & Combo Box - Change event making problems, Help, Urgent

Status
Not open for further replies.

bzac

Programmer
Dec 20, 2000
55
US
Whenever making a reference to the field which is assigned to a Text Box or Combo box, it is going and check the change_event routine. How can I prevent this for running the change-event only when the user actually change the Combo box or Text Box ?.

1)here on doubleclick the text has to be displayed in the text box.

Private Sub mshgridcustomer_DblClick()
If mshgridCustomer.Rows > 0 Then
With mshgridCustomer
'.Row = .MouseRow + 1
.Row = .MouseRow
.Col = 0
unitid = .Text
txtid.Text = unitid
.Col = 1
txtcustname.Text = .Text
::::::::::
End With
End If
::::::::
End Sub

2)Below procedure is to set the ComboBox in Form_load. In this case also it is wasting time by going and checking the Change_event of the ComboBox!!

Private Sub SetCombo()
:::::::::::
Set cboplsystem.DataSource = adoCustRS1
Set cboplsystem.RowSource = adoCustRS1
End Sub

Is there any better way for getting thru.

Please help me as soon as possible, I am about to test run the program with actual data.

Thank you
 
I had the same issue where i was filling many combo's and from a DB and their change events were firing and wasting time. The way i solved it was to define a Public variable called UpdateNow As Boolean. In the form load procedure i set it to false.
Code:
Private Sub Form_Load()

   UpdateNow = False 
   .
   .
   .
   Update Now = True 
End Sub
Then in the event procedures you want to turn off, surround all the code with an if..then, like this.
Code:
Private Sub Combo1_Change() 
   If UpdateNow = True Then 
      'all the event code goes here 
   End If 
End Sub
This won't exactly skip going into the event, but it will make it a whole lot quicker than running the event procedure each time.

Ruairi

Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
 
Thank You very much Ruairi. Even I also tried the same way, but don't think that is the better way. I am sure somebody can give us a better idea, please.

Thank You
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top