time/timing/breakpoint

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

A button in my form is supposed to assign the actual time to tbtime, which
has a ControlSource assigned.

Private Sub cbtime_Click()
tbtime.Value = Time
Call bnNext_Click
End Sub

The "next" part works. The "time" part
doesn't work
- without breakpoint
- with breakpoint and "Continue"
does work
- with breakpoint and F8

"breakpoint" refers to a breakpoint at tbtime.value = time

Could somebody illuminate me? Why does this happen and how can I correct the
problem?

Oskar von dem Hagen
 
Not sure I fully understand.

What is btnNext, and what does it do? I assume tbTime is a textbox. What
relevance does ControlSource have?
 
Apologies if I was too brief. :-)

Excel 2000, Windows 2000 SP 4. The modeless form loads a row of an excel
table. Most of the fields in the form are linked to cells in that row (e.g.
the textbox tbtime may have the controlsource AW18).

The button cbtime is supposed to set the textbox tbtime (and the cell AW18)
to the actual time and then proceeds to the next record (row) by "pressing"
the button cbnext.

Pressing cbtime without breakpoint leaves AW18 empty and proceeds to the
next record. Setting a breakpoint and executing stepwise sets the time as
intended and then proceeds to the next record.

Oska von dem Hagen
 
I guess the reason you are seeing it populated in step mode is because it is
getting cleared out later, and that normally happens so fast that you don't
see it. Something like

- time button clicked
- textbox populated
- cell populated
- something then clears textbox, and hence cell

So in step mode, you will see data in the cell before the 4th step.

Do you load the tbTime textbox when you hit the next button? If so, and the
source is blank, that will be the cause, as cell AW18 being linked to the
textbox will also clear down.

Do want to show the whole form code?
 
The whole code is a bit messy. (I hope the excerpt, see below, contains all
relevant information.). It's basically an applied example from Bullen et al.
modified to have formulas as database entries and using a class module to
catch PgDn/PgUp keys.

If I use step mode, the cell remains populated.

Oskar von dem Hagen

P.S. (Longer) Code excerpt:
Private Sub UserForm_Initialize()
Dim temp As Integer
[...]
'Load 1st record in Datenbank and initialise scrollbar
With Range("Datenbank")
temp = ActiveCell.Row - 12
sbNavigator.Max = .Rows.Count
If Not (temp > 2) Then
sbNavigator.Value = 2
Set rgData = .Rows(sbNavigator.Value)
Call LoadRecord
ElseIf Not (temp <= sbNavigator.Max) Then
sbNavigator.Value = sbNavigator.Max
Else
sbNavigator.Value = temp
End If
End With
[...]
End Sub

Private Sub LoadRecord()
[...]
tbtime.ControlSource = rgData.Cells(1, 49).Address()
End Sub

Private Sub sbNavigator_Change()
'When Scrollbar value changes, save current record and load
'record number corresponding to scrollbar value
Set rgData = Range("Datenbank").Rows(sbNavigator.Value)
[D12].Value = sbNavigator.Value
Call LoadRecord
End Sub

Public Sub bnNext_Click()
With Range("Datenbank")
If rgData.Row < .Rows(.Rows.Count).Row Then
'Load next record only if not on last record
sbNavigator.Value = sbNavigator.Value + 1
'Note: Setting sbNavigator.Value runs its Change event procedure
End If
End With
End Sub

Private Sub cbtime_Click()
tbtime.Value = Time
Call bnNext_Click
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top