ListBox Operation Putting Form Into Some Kind Of State?

P

(PeteCresswell)

When this code runs:
---------------------------------
3030 With Me.lstIssuers
3031 If .ListCount > 0 Then
3032 .SetFocus
3033 .ListIndex = 0 'Force selection of first row
3034 End If
3035 End With
3036 Me.cmdClose.SetFocus
---------------------------------

It traps out on line# 3036.

If I rem that line out, it will trap out on the next statement
that attempts to do a .SetFocus to some other control

The error is 2110 "Can't move focus to control" and if I step
through the code, the explanation that pops is

"Macro or function set to BeforeUpdate or ValidateRule property
for this field is preventing [application name] from saving data
in the field."

If I rem out the offending code (lined 3030-3026) there are no
problems.

Anybody been here?
 
D

Dirk Goldgar

In
(PeteCresswell) said:
When this code runs:
---------------------------------
3030 With Me.lstIssuers
3031 If .ListCount > 0 Then
3032 .SetFocus
3033 .ListIndex = 0 'Force selection of first row
3034 End If
3035 End With
3036 Me.cmdClose.SetFocus
---------------------------------

It traps out on line# 3036.

If I rem that line out, it will trap out on the next statement
that attempts to do a .SetFocus to some other control

The error is 2110 "Can't move focus to control" and if I step
through the code, the explanation that pops is

"Macro or function set to BeforeUpdate or ValidateRule property
for this field is preventing [application name] from saving data
in the field."

If I rem out the offending code (lined 3030-3026) there are no
problems.

Anybody been here?

No, but if this is a single-select list box, try ditching the SetFocus
and selecting the first item this way:

With Me.lstIssuers
If .ListCount > 0 Then
.Value = .ItemData(0)
End If
End With

That's also assuming that the control's ColumnHeads property is set to
False. Otherwise a small amendment is necessary.
 
P

(PeteCresswell)

Per Dirk Goldgar:
No, but if this is a single-select list box, try ditching the SetFocus
and selecting the first item this way:

With Me.lstIssuers
If .ListCount > 0 Then
.Value = .ItemData(0)
End If
End With

That's also assuming that the control's ColumnHeads property is set to
False. Otherwise a small amendment is necessary.

Worked like a charm.

Thanks!!!
 
Top