Check multiple form items

  • Thread starter Thread starter jbiggs via AccessMonster.com
  • Start date Start date
J

jbiggs via AccessMonster.com

I am using the following piece of code to check a record from a form:

If Me![Task List subform].Form.[Lead Status] = "Unworked Lead" Then
.....
End If

The problem is that this only checks the top record in the form. How can I
make it recurse through all the records and check them all?
 
jbiggs said:
I am using the following piece of code to check a record from a form:

If Me![Task List subform].Form.[Lead Status] = "Unworked Lead" Then
....
End If

The problem is that this only checks the top record in the form. How can I
make it recurse through all the records and check them all?


What are you doing with the records that have "Unworked
Lead"? It's pretty easy to display a count of those
records, but other thing are highly dependent on what you
are trying to do.

To answer your specific question (even if it might not help
with your larger problem);

With Me.RecordsetClone
.MoveFirst
Do Until .EOF
If ![Lead Status] = "Unworked Lead" Then
....
End If
.MoveNext
Loop
End With
 
Hi Marshall,

I am trying to disallow an action if a record marked 'Unworked Lead' exists
(by exiting the sub).

Marshall said:
I am using the following piece of code to check a record from a form:
[quoted text clipped - 4 lines]
The problem is that this only checks the top record in the form. How can I
make it recurse through all the records and check them all?

What are you doing with the records that have "Unworked
Lead"? It's pretty easy to display a count of those
records, but other thing are highly dependent on what you
are trying to do.

To answer your specific question (even if it might not help
with your larger problem);

With Me.RecordsetClone
.MoveFirst
Do Until .EOF
If ![Lead Status] = "Unworked Lead" Then
....
End If
.MoveNext
Loop
End With
 
I just tried using your code block and I'm getting an error:

"Item not found in collection"

Don't I need to specify the 'Task list subform' somewhere?

Marshall said:
I am using the following piece of code to check a record from a form:
[quoted text clipped - 4 lines]
The problem is that this only checks the top record in the form. How can I
make it recurse through all the records and check them all?

What are you doing with the records that have "Unworked
Lead"? It's pretty easy to display a count of those
records, but other thing are highly dependent on what you
are trying to do.

To answer your specific question (even if it might not help
with your larger problem);

With Me.RecordsetClone
.MoveFirst
Do Until .EOF
If ![Lead Status] = "Unworked Lead" Then
....
End If
.MoveNext
Loop
End With
 
Sorry, I forgot the subform bit.

Change the With statement:
With Me![Task List subform].Form.RecordsetClone
--
Marsh
MVP [MS Access]

I just tried using your code block and I'm getting an error:

"Item not found in collection"

Don't I need to specify the 'Task list subform' somewhere?

Marshall said:
I am using the following piece of code to check a record from a form:
[quoted text clipped - 4 lines]
The problem is that this only checks the top record in the form. How can I
make it recurse through all the records and check them all?

What are you doing with the records that have "Unworked
Lead"? It's pretty easy to display a count of those
records, but other thing are highly dependent on what you
are trying to do.

To answer your specific question (even if it might not help
with your larger problem);

With Me.RecordsetClone
.MoveFirst
Do Until .EOF
If ![Lead Status] = "Unworked Lead" Then
....
End If
.MoveNext
Loop
End With
 
This line:

If ![Lead Status] = "Unworked Lead" Then

Is giving me an "item not found in this collection error.

Marshall said:
Sorry, I forgot the subform bit.

Change the With statement:
With Me![Task List subform].Form.RecordsetClone
I just tried using your code block and I'm getting an error:
[quoted text clipped - 25 lines]
 
jbiggs said:
This line:

If ![Lead Status] = "Unworked Lead" Then

Is giving me an "item not found in this collection error.


Replace [Lead Status] with the name of the corresponding
field in the subform's record source table/query. If the
field is not in the record source table/query, then you need
to add it.
 
Back
Top