Results 1 to 11 of 11
  1. #1
    Join Date
    Aug 2004
    Posts
    364

    Unanswered: Best way to use a Check-Box on a Continuous Form?

    What would be the most suitable way to place an unbound check-box onto a form which is set to display as continuous? If there are 5 records showing, there will be 5 checkboxes, but all of them will become checked regardless of which one I select.

    I have found a way on the internet to add a transparent command button and use this code to get around it, but it seems a bit fiddly, is there another alternative such as making an extra field in a query or any other way?

    Here is the code I found -
    Code:
    Dim colCheckBox      As New Collection
    
    
    Public Function IsChecked(vID As Variant) As Boolean
    
       Dim lngID      As Long
       
       IsChecked = False
       
       On Error GoTo exit1
       
       lngID = colCheckBox(CStr(vID))
       If lngID <> 0 Then
          IsChecked = True
       End If
       
    exit1:
       
    End Function
    
    Private Sub Command13_Click()
    Debug.Print "contact = " & Me.linkLocationItemID
    
       If IsChecked(Me.linkLocationItemID) = False Then
          colCheckBox.Add CLng(Me.linkLocationItemID), CStr(Me.linkLocationItemID)
       Else
          colCheckBox.Remove (CStr(Me.linkLocationItemID))
       End If
       Me.check11.Requery
       
    End Sub
    
    Private Function MySelected() As String
    
       Dim i       As Integer
         
       For i = 1 To colCheckBox.Count
          If MySelected <> "" Then
             MySelected = MySelected & ","
          End If
          MySelected = MySelected & colCheckBox(i)
          
       Next i
       
    End Function
    And the you have to set the check box (check11) behind the transparent command button (command13) to "=IsChecked([linkLocationItemID])"
    The reason I would like to place check boxes on a continuous form is so I can "tick" a record, then view it by clicking a command button. The link to the example I found is this and is titled Multi Select Example

  2. #2
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    I suggest to BOUND the check box field, (look at table "tblOrder",
    and "Form1". On Close "Form1" run an update query and set the
    check boxes on 0, (look at "Form1" VBA, and "Query1Update".

    Look at "DemoCheckBoxContA2000.mdb" (attachment, zip).
    Open Form and try.
    Attached Files Attached Files

  3. #3
    Join Date
    Oct 2009
    Posts
    340
    as the previous post suggests; you must either go with single form - or you need to add that checkbox to your underlying table record source.....

    just because the chkbox is bound doesn't mean you can't dynamically add/delete/ignore data using some creative Updatequery in the background....

    it is the nature of continous forms....

  4. #4
    Join Date
    Aug 2004
    Posts
    364
    Quote Originally Posted by MStef-ZG View Post
    I suggest to BOUND the check box field, (look at table "tblOrder",
    and "Form1". On Close "Form1" run an update query and set the
    check boxes on 0, (look at "Form1" VBA, and "Query1Update".

    Look at "DemoCheckBoxContA2000.mdb" (attachment, zip).
    Open Form and try.
    That is brilliant, thankyou so much!!

  5. #5
    Join Date
    Jul 2010
    Posts
    1
    I am trying to use a check box with a continuous form as well. However, the example would not work for me because my form is an underlying QUERY, not an underlying table. My form is based on material from a table, and there is information in the form that it looks up, which is why I used an underlying query. Like moss, I wanted to have check boxes so I could pick more records to do print or do something else with. Any suggetions on how to go about this?

  6. #6
    Join Date
    Oct 2009
    Posts
    340
    well - an unbound control and continuous forms do not work together and so you must take another route.

    the fact that your record source is a query does not defacto eliminate putting the checkbox in the underlying table; but I will hazard the guess that what you meaning to say is that the query is not updateable - which makes this approach not viable because one can't check the checkbox....

    in which case you probably want to take the query record set - and write it to a table that does have a checkbox; using an AppendQuery. Source your form on this temp table. there will be of course supplementary house keeping to manage/delete/clean the temp table.

  7. #7
    Join Date
    May 2010
    Posts
    601
    Pardon me for jumping in ... there is an alternative.

    It is possible to have Unbound checkboxes. Albert Kallal demonstrates it with his example here.
    Last edited by HiTechCoach; 07-26-10 at 16:48.
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  8. #8
    Join Date
    Oct 2009
    Posts
    340
    It is welcomed input. An approach not for the novice maybe - but there it is.

    Generically - there are many that struggle with an unbound control in a continuous form - - and in general it is not a viable combination. It is not a topic typically covered well in textbooks. For most, making the control exist in the underlying record set is the most straight forward approach.

  9. #9
    Join Date
    May 2010
    Posts
    601
    Quote Originally Posted by NTC View Post
    It is welcomed input. An approach not for the novice maybe - but there it is.

    Generically - there are many that struggle with an unbound control in a continuous form - - and in general it is not a viable combination. It is not a topic typically covered well in textbooks. For most, making the control exist in the underlying record set is the most straight forward approach.
    I totally agree.

    For the more advanced members reading this post, I hope that they might find it helpful.
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  10. #10
    Join Date
    Jun 2013
    Posts
    2
    If I am understanding the question, I believe a viable alternative is using a List Box in MultiSelect mode.
    Access MultiSelect List Box with VBA Digital Reins

    This control is perfect to loop through selected records.

  11. #11
    Join Date
    May 2010
    Posts
    601
    DigitalReins, I agree that a ListBox in MultiSelect mode may be a viable alternative.
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •