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!

Stepping through code dislpays weird behaviour

Status
Not open for further replies.

t16turbo

Programmer
Mar 22, 2005
315
GB
I have a macro that is kicked off by a subroutine button click:

Code:
Private Sub CommandButton1_Click()
Man = TextBox1.Value
Call AutoFOB(Man)

End Sub
_________________________________________________
Private Sub ListBox1_Click()
TextBox1.Value = ListBox1.Value
End Sub

if I step through the code, it seems to return to the Private Sub ListBox1_Click()
routine every time it performs a funtion
e.g.

Code:
With Sheets("Development and Design").QueryTables(1)
            .Destination = Sheets("Development and Design").Cells(1, 1)
            .Connection = sConn
            .CommandText = sSQL
            .Refresh BackgroundQuery:=False
            End With
in the above code, when it runs the ".Destination = Sheets..." line, it goes to the ListBox1_Click Subroutine and goes through it twice, before returning to the macro.
then after the ".Refresh BackgroundQuery.." line, it goes back to the ListBox1_Click and goes through ti twice. etc


it does this every time it comes to similar code in the rest of my macro.

any ideas???

 
Is the list box on a form or on the worksheet?
Is the list box somehow linked to cell(1, 1)?

If there is a link, and the list box contents is updated because the value in cell(1, 1) changes, that may be calling the click event.

I have had a similar situation with option buttons and check boxes that have On_Change code associated with them. When you change the value of the object, it automatically calls the code for the object.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top