Results 1 to 9 of 9
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Listbox group query row source only show mainform id

    I have a main form with areas and their id



    it's a continuous form.

    I have a listbox which shows much the same thing however the row source is showing a query that is grouped with totals. I need to only show the id of the same area.

    I thought having areaID with a where "forms!frmSchoolAreasClear!AreaID" in the group would work to only show the results that areaid from the mainform

    Is this possible? to have the listbox on each continous form to show only what the same ID?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Not sure I understand. You want a listbox RowSource to be dependent on the AreaID of current record so it will show only records with that AreaID? The RowSource is an aggregate query? The filtered RowSource would be a single item?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Not sure I understand. You want a listbox RowSource to be dependent on the AreaID of current record so it will show only records with that AreaID? The RowSource is an aggregate query? The filtered RowSource would be a single item?
    Yes you have it - I wonder if this is possible. I can get the area to "select" what is in the list but I just want to show instead.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    If I do understand correctly what you want, yes - it works for me.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    If I do understand correctly what you want, yes - it works for me.
    How do I go about getting it to work? I figured the where would give me the result but it shows up blank.

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Nevermind I used a dcount on an unbound text box to get the same result (which is better anyway.... )

    Now I have to make it so any check box on a continuous form that is checked gets cleared - I'm hoping I can do that on the mainform without having to have a subform/datasheet.

    Click image for larger version. 

Name:	Capture.JPG 
Views:	7 
Size:	34.0 KB 
ID:	14005

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Are those checkboxes bound to a field? Won't work with unbound checkbox - checkbox will have the same value.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Are those checkboxes bound to a field? Won't work with unbound checkbox - checkbox will have the same value.
    They're bound to the area table field "CheckToClear".

    I was thinking of using some code I found:

    Code:
    Function TickOnOff(FormName As String, FieldName As String, TickBoxName As String)Dim RecordSourceName As String
    Dim Switch1 As String
    Dim MySql As String
    RecordSourceName = Forms(FormName).RecordSource
    Switch1 = Forms(FormName).Controls(TickBoxName).Value
    MySql = "UPDATE " + RecordSourceName + " SET " + RecordSourceName + "." + FieldName + " = " + Switch1 + ";"
    DoCmd.SetWarnings False
    DoCmd.RunSQL MySql
    DoCmd.SetWarnings True
    Forms(FormName).Controls(TickBoxName).Requery
    End Function
    If I exchange the fields for mine, and the forms for mine as well as the criteria for the update. Really I want to clear the date field in the tblSchools that correlate with the same AreaID that is in the areas table (the main form with the checkboxes).

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The form RecordSource is a table or query object, not an SQL statement?

    Maybe:

    Function TickOnOff(FormName As String, FieldName As String, TickBoxName As String)
    Dim RecordSourceName As String Dim Switch1 As String Dim MySql As String RecordSourceName = Forms(FormName).RecordSource Switch1 = Forms(FormName).Controls(TickBoxName).Value MySql = "UPDATE " & RecordSourceName & " SET " & RecordSourceName & "." & FieldName & " = " & Switch1 & " WHERE checkfield = True;" CurrentDb.Execute MySql
    'do you need to reset all checkboxes back to False?
    CurrentDB.Execute "UPDATE " & RecordSourceName & " SET checkfield=False" Forms(FormName).Controls(TickBoxName).Requery End Function
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Requery Does Not Update Listbox Row Source
    By szucker1 in forum Forms
    Replies: 7
    Last Post: 02-11-2014, 08:58 AM
  2. Requery ListBox on Mainform from Subform
    By Ruegen in forum Forms
    Replies: 11
    Last Post: 10-29-2013, 09:27 PM
  3. option group pass different value to same listbox
    By ice051505 in forum Programming
    Replies: 11
    Last Post: 03-12-2013, 11:52 AM
  4. Replies: 4
    Last Post: 11-26-2012, 07:17 AM
  5. Replies: 2
    Last Post: 06-21-2012, 07:40 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