Selecting particular records in a form

  • Thread starter Thread starter Emma
  • Start date Start date
E

Emma

I have a form which lists all of my records with a
checkbox next to them for selecting. At the top of the
form is a box, ckPacifiCorp, which should select all
records with a PacifiCorp as the "Contact Type" for the
user. However, it seems to only look at the Contact Type
for the first record and then select or not select all
records based on that one record's field. It doesn't seem
to be moving to the next record. Could anyone help?
Here's the code I'm using:

Dim rs As Recordset

Me.Refresh
Set rs = Me.RecordsetClone
If rs.RecordCount > 0 Then
rs.MoveFirst
Do Until rs.EOF
rs.Edit
If [ContactType].Value = "PacifiCorp"
Then rs!PrintFlag = (Me!ckPacifiCorp = True)
rs.Update
rs.MoveNext
Loop
End If
Me.Refresh



TIA!
 
I am not sure I quite understand what your code is doing but I think you
want to be working with the Recordset property, not RecordsetClone.
Updating RecordsetClone is kind of pointless, I think.

Pavel
 
The basis of the code is straight from the Contact
Management template in Access. I'm not honestly sure I
understand the difference between the Recordset and
Recordset clone. The checkbox which allows you to select
or deselect all records is the one the template sets up
and it works fine. It's only when I put in the "If
[contact type]=..." part that I start having problems.

-----Original Message-----
I am not sure I quite understand what your code is doing but I think you
want to be working with the Recordset property, not RecordsetClone.
Updating RecordsetClone is kind of pointless, I think.

Pavel
I have a form which lists all of my records with a
checkbox next to them for selecting. At the top of the
form is a box, ckPacifiCorp, which should select all
records with a PacifiCorp as the "Contact Type" for the
user. However, it seems to only look at the Contact Type
for the first record and then select or not select all
records based on that one record's field. It doesn't seem
to be moving to the next record. Could anyone help?
Here's the code I'm using:

Dim rs As Recordset

Me.Refresh
Set rs = Me.RecordsetClone
If rs.RecordCount > 0 Then
rs.MoveFirst
Do Until rs.EOF
rs.Edit
If [ContactType].Value = "PacifiCorp"
Then rs!PrintFlag = (Me!ckPacifiCorp = True)
rs.Update
rs.MoveNext
Loop
End If
Me.Refresh

TIA!
.
 
I got it! I just had to add "rs!" before
the "[ContactType].Value..." part of my If statement.
Thanks!

-----Original Message-----
The basis of the code is straight from the Contact
Management template in Access. I'm not honestly sure I
understand the difference between the Recordset and
Recordset clone. The checkbox which allows you to select
or deselect all records is the one the template sets up
and it works fine. It's only when I put in the "If
[contact type]=..." part that I start having problems.

-----Original Message-----
I am not sure I quite understand what your code is
doing
but I think you
want to be working with the Recordset property, not RecordsetClone.
Updating RecordsetClone is kind of pointless, I think.

Pavel
I have a form which lists all of my records with a
checkbox next to them for selecting. At the top of the
form is a box, ckPacifiCorp, which should select all
records with a PacifiCorp as the "Contact Type" for the
user. However, it seems to only look at the Contact Type
for the first record and then select or not select all
records based on that one record's field. It doesn't seem
to be moving to the next record. Could anyone help?
Here's the code I'm using:

Dim rs As Recordset

Me.Refresh
Set rs = Me.RecordsetClone
If rs.RecordCount > 0 Then
rs.MoveFirst
Do Until rs.EOF
rs.Edit
If [ContactType].Value = "PacifiCorp"
Then rs!PrintFlag = (Me!ckPacifiCorp = True)
rs.Update
rs.MoveNext
Loop
End If
Me.Refresh

TIA!
.
.
 
Back
Top