Results 1 to 6 of 6
  1. #1
    krizzyd is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Posts
    4

    Requery Checked Checkboxes with Combobox

    Hello guys,

    I want to re-query my subform using the values in my combo box. To be specific, I need an AfterUpdate code that will make the combo box re-query the data to select a certain field where its checkboxes are true, along with the "Volunteer" field associated with it (neglecting other fields other than the combo box value and Volunteer).

    Attached is a screenshot if it helps. The values in my combo box correspond with the fields in my subform in datasheet view.

    Any help is appreciated!

    Click image for larger version. 

Name:	ss+(2016-11-28+at+03.45.03).png 
Views:	13 
Size:	55.6 KB 
ID:	26571

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Create the SQL for the record source in the AfterUpdate of the combobox and requery the form.

    Me.Recordsource="SELECT xxx FROM xxx WHERE " & Me!ComboboxName & "=True;"
    Me.Requery

  3. #3
    krizzyd is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Posts
    4
    Thanks for the reply.

    But how do I reference my Employment Type fields when selecting them? I only want to select one at a time depending on the field chosen in the combo box :P

    So I have:

    Me.RecordSource = "SELECT qry_EmploymentType.Volunteer,qry.EmploymentType.[What do I put here?] FROM qry.EmploymentType WHERE " & Me!ComboboxName & "=True;"
    Me.Requery

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I assumed that the Employment Type field name was the same as that displayed in the combobox/heading. Post the SQL of the record source of the form.

  5. #5
    krizzyd is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Posts
    4
    Yes, the fields in the combo box are the same as the field column names. Not sure what you meant by "record source" but to be more specific, I have a navigation form and a subform (the one I posted a picture of last post), and with the code I'm currently using it gives me the results as shown in the attachment.

    My exact SQL Afterupdate code is:

    Private Sub cboEmploymentType_AfterUpdate()
    Me.form_Empt.Form.RecordSource = "Select qry_EmploymentType.Volunteer,qry_EmploymentType.['" & Me.cboEmploymentType & "'] from qry_EmploymentType where '" & Me.cboEmploymentType & "' =True;"
    Me.form_Empt.Form.Requery
    End Sub

    Please let me know if this makes sense.

    EDIT: The name of the Navigation form is "Navigation Form", the subform is called "Employment Type" and within "Employment Type" there's another form (created from qry_EmploymentType) called "form_Empt". Hope this information helps.

    Click image for larger version. 

Name:	ss+(2016-11-29+at+05.46.54).png 
Views:	5 
Size:	42.3 KB 
ID:	26587

  6. #6
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Yes, the fields in the combo box are the same as the field column names
    That cannot be true - otherwise you would not be getting that error that is show above.

    Not sure what you meant by "record source"
    When you are in design view and you show the property sheet, this property tells you where the data is coming from. What is the name of the form shown here, the one with the actual rows of data? And what is its record source - is it qry_EmploymentType? Bottom line, the record source for the form showing the data will tell us the names of the checkbox fields, then we can make a new SQL statement dependent on your entry.

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

Similar Threads

  1. Replies: 7
    Last Post: 03-17-2016, 10:42 AM
  2. help regarding Combobox linking with checkboxes
    By aparnawangu in forum Forms
    Replies: 5
    Last Post: 07-24-2015, 06:57 AM
  3. Update records with checkboxes checked VBA
    By excellenthelp in forum Access
    Replies: 3
    Last Post: 12-24-2014, 09:48 AM
  4. Replies: 54
    Last Post: 07-17-2013, 03:01 PM
  5. No Results on Requery for Combobox RowSource
    By dccjr in forum Programming
    Replies: 3
    Last Post: 05-10-2013, 06:08 PM

Tags for this Thread

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