Is it posible theway I do this ?
I have a form with 5 textfields and 2 listbox. Some of them are mandatory, others not . A user must fill/select the fields , but sometimes (unfortunately) he can hit the acceptbutton while not all fields are filled in. I mark in another sheet if a textfield is ok . When pushing the accept-button, i control if there are still unfilled fields and i want to set the cursor to that empty field and set the backcolor and the focus to the field
I wrote :
Dim idx As Integer
Dim ctl As Control
idx = xx ' tabindex of the empty textfield , xx is the return of a function, which works correct
For Each ctl In Me.Controls
If ctl.TabIndex = idx Then
ctl.Name.BackColor = vbYellow ---> doesnot work
ctl.SetFocus --> doesnot work
MsgBox ctl.Name & " niet ingevuld of geselecteerd"
Exit For
End If
Next
How resolve ?
I have a form with 5 textfields and 2 listbox. Some of them are mandatory, others not . A user must fill/select the fields , but sometimes (unfortunately) he can hit the acceptbutton while not all fields are filled in. I mark in another sheet if a textfield is ok . When pushing the accept-button, i control if there are still unfilled fields and i want to set the cursor to that empty field and set the backcolor and the focus to the field
I wrote :
Dim idx As Integer
Dim ctl As Control
idx = xx ' tabindex of the empty textfield , xx is the return of a function, which works correct
For Each ctl In Me.Controls
If ctl.TabIndex = idx Then
ctl.Name.BackColor = vbYellow ---> doesnot work
ctl.SetFocus --> doesnot work
MsgBox ctl.Name & " niet ingevuld of geselecteerd"
Exit For
End If
Next
How resolve ?