Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check box in continous form 2

Status
Not open for further replies.

integritycare

Technical User
Mar 12, 2011
151
AU
Hello,
Below is some code I found in the forums. Have tried to use it on a continous form so that only a single record can be selected at one time.
However I get an error saying that "data or member not found." It highlights (.Edit) as the error.


Code:
Dim rst As Recordset

Set rst = Me.RecordsetClone
With rst
.MoveFirst
Do While Not .EOF
.Edit
rst![CheckBoxFieldName] = False
.Update
.MoveNext
Loop
End With
rst.Close
Set rst = Nothing

Any help would be appreciated.

Regards,

Integrity
 
I'd try this:
Dim rst As [!]DAO.[/!]Recordset

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV,

Many thanks for your help.
Did this now the error highlighted is "rst"
Code:
rst![Use] = False
Just says, "Invalid use of Property:

Do you have any futher ideas?

Integrity


 
Perhaps this ?
rst.Fields("Use").Value = False

BTW, you really have a column named Use in the underlaying query ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya integritycare . . .

The following should also work:
Code:
[blue]rst[b]!Use[/b] = False[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Hi PHV,
Again Thankyou for your reply.
Now while there are no errors, when I put a check into the check box it just scrolls through all the records.
What I was aiming for was for the user to be able to select a record, then when the user goes to select the next record, the previous check box would default to false. So that on the continous form only one record can be selected at any ont time.

Perhaps the code I was using is not for what is intended. have you been able to achive this in any of your databases?

Regards,

Integrity
 
integritycare . . .

If you indent your code, it always makes for easier reading ...

Code:
[blue]   Dim rst As DAO.Recordset
   
   Set rst = Me.RecordsetClone
   
   With rst
      .MoveFirst
      
      Do While Not .EOF
         .Edit
         ![CheckBoxFieldName] = False
         .Update
         .MoveNext
      Loop
   End With
   
   Set rst = Nothing[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
integritycare said:
[blue]Perhaps the code I was using is not for what is intended ...[/blue]
Well ... it almost meets your requirements. The code simply removes all checks. You need a way to skip the selected record. Here's an example using the primarykey:
Code:
[blue]   Dim rst As DAO.Recordset, pkName As String
   
   Set rst = Me.RecordsetClone
   rst.MoveFirst
   pkName = "[COLOR=#204A87][b]YourPrimarykeyNameHere[/b][/color]"
   
   Do Until rst.EOF
      If rst(pkName) <> Me(pkName) Then
         rst.Edit
         rst!Use = False
         rst.Update
      End If

      rst.MoveNext
   Loop

   Set rst = Nothing[/blue]
You may need modifications depending on wether primarykey is string or numeric.

[blue]Your Thoughts? ...[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Hi TheAceman1,
Thanks for your reply. This works great. I did take your point about indenting code..
That i will do in the future.

Again many thanks.

Integrity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top