Results 1 to 4 of 4
  1. #1
    NBCarroll is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2015
    Posts
    3

    Load form based on checkbox selection in continuous form

    Hi there,



    I have a continuous form with a button in the form header. I want to set conditions on the on_click event of the button to load a form if a checkbox on any record is true. The checkbox is called "BulkMove". At the moment with everything I've tried I can only get it to work if the first records checkbox is ticked. If any other records are ticked and the first record is left unticked, it does not open the form.

    I hope this explains what I'm trying to achieve. Note the data in the continuous form is a query which is editable directly (there are no joins that stop the data from being edited, thus the checkboxes can be ticked or unticked).


    Cheers,
    Nick

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    Can you post the code you are using to open the form. It seems the conditions you are using are not met with/referred in your code to open the form, hence only first record is picked. The checkbox is a bound to a field in table, right ?

  3. #3
    NBCarroll is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2015
    Posts
    3
    Hi, thanks for the response.

    Yes the checkbox is bound to a field in a table.
    I've been looking around and tried this, but i think I'm not on the right track so forgive me if it's way out:

    Code:
    Private Sub RelocateItemButton_Click()
    Dim db As Object
    Dim rst As Object
    
    
        Set db = Application.CurrentDb
        Set rst = Me.RecordsetClone
    
    
            If rst.RecordCount = 0 Then
                MsgBox "There are no items to move"
                Exit Sub
            End If
           
            If Me.BulkMove = True Then
                DoCmd.OpenForm "FRM-InventoryTracking-RelocateItem", acNormal
            Else
                rst.MoveFirst
                Do Until rst.EOF
                    If BulkMove = True Then
                        DoCmd.OpenForm "FRM-InventoryTracking-RelocateItem", acNormal
                    End If
                rst.MoveNext
                Loop
                rst.Close
            End If
    
    
    End Sub
    Last edited by NBCarroll; 04-10-2015 at 09:59 PM. Reason: Forgot to answer a question

  4. #4
    NBCarroll is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2015
    Posts
    3
    All good now! I figured it out. I needed to reference to the recordset BulkMove control. See the code below that works (putting it here in case anyone else needs it):


    This code specifically checks the first records checkbox to see if it is marked as TRUE or FALSE. If it is FALSE then it moves through to records one at a time. The next IF statement checks the recordset checkbox to see if it is True. If True it opens the required form.

    This works on a continuous form with a query behind it which is editable.

    In a nutshell, the code will look at all checkboxes in the list and open a form if any one of them is marked as true.


    Code:
    Dim db As Object
    Dim rst As Object
    
    
        Set db = Application.CurrentDb
        Set rst = Me.RecordsetClone
    
    
            If rst.RecordCount = 0 Then
                MsgBox "There are no items to move"
                Exit Sub
            End If
           
            If Me.BulkMove = False Then
                rst.MoveFirst
                Do Until rst.EOF
                    If rst!BulkMove = True Then
                        DoCmd.OpenForm "FRM-InventoryTracking-RelocateItem", acNormal
                    End If
                rst.MoveNext
                Loop
                rst.Close
            Else
            DoCmd.OpenForm "FRM-InventoryTracking-RelocateItem", acNormal
            End If
    
    
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 10-28-2014, 03:55 AM
  2. Replies: 2
    Last Post: 01-01-2014, 02:10 PM
  3. Continuous Form With Checkbox VB Problem
    By WhiskyLima in forum Access
    Replies: 4
    Last Post: 11-25-2013, 08:25 AM
  4. Replies: 2
    Last Post: 10-09-2012, 10:07 AM
  5. Replies: 3
    Last Post: 10-31-2011, 04:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums