for each control find null control (1 Viewer)

bibo_1dd

New member
Local time
Today, 05:57
Joined
Aug 2, 2009
Messages
3
hi all i want to find all and pause and set focused on empty control box on access form

the control box named q1-q2-------q60
some control have no value i
iwant when i press enter jump to empty control and skip others

this is code but no way
***********************
On Error Resume Next
Dim r, i As Integer
Dim strActiveCtl As String
Dim Ctlnm As String
Me.Controls("q" & x).SetFocus
For Each ctl In Forms!correc.Controls
Me.Controls("q" & x).SetFocus
Ctlnm = ctl.name
If InStr(Ctlnm, "q") Then
Select Case ctl.Value
Case Is = Null
ctl.Value = "f"
x = x + 1
End Select
End If
Next
**********************
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:57
Joined
Oct 29, 2018
Messages
21,474
Try using the IsNull() function instead to check for a Null value.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:57
Joined
Feb 28, 2001
Messages
27,191
Beware of the fact that empty controls and null controls are different, which is why you have an IsNull function and an IsEmpty function. Also, you have a For Each ctl loop but I doubt that your code as written will limit your loop to qxxx controls. Your value "x" doesn't seem to come from anywhere, so I hope you have a control named q (with no number). Your loop steps through x, but doesn't initialize it. I'm not sure, but it is possible that attempting to set focus to a control that cannot be enabled would also fail with an error, and your code sequence doesn't seem to enforce that limitation.

I'm going to take a wild guess that you named your controls q1-q60 because you are doing a questionnaire and potentially have 60 questions. You might wish to search this forum for the topic "questionnaire" to see more about that topic.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:57
Joined
Feb 19, 2002
Messages
43,293
Normalizing the data is the solution to your problem. It is the solution to oh so many non-problems.
 

Users who are viewing this thread

Top Bottom