Results 1 to 8 of 8

Return 'Surname' 'Name' and 'Member number' and field based on combo box.

  1. #1
    stockers is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    4

    Return 'Surname' 'Name' and 'Member number' and field based on combo box.

    Hi All



    I have a database that in tblmemberdetails there are a number of fields including Member No, Surname and Name however there's also 1-20, 1-21 and so on.

    On a form i have a Combo Box with the field names from tblmemberdetails.

    When I select the relevant field in the combobox and press another button (which will be 1-20 on wards) i would like it to return the 'Surname', 'Name' and 'Member No' where the value is True for the field selected in the combobox. Ultimately i would like it in a report however if i can get it working in a query i can then set it up in a report.

    Is there a way of doing this?

    Thank you in advance.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    41,130
    Don't need to press another button. Expression in textbox can reference the combobox columns by index. Index begins with 0 so column 2 has index 1, like: = [comboboxname].[Column](1).

    A query used as RecordSource for report would include tblmemberdetails joined to whatever other table you are saving the ward id in.
    To provide db: Make copy, remove confidential data, run compact & repair, zip w/Windows Compression if over 500KB (2MB zip allowed), attach to post. Attachment Manager is below the Advanced post editor window, click Go Advanced below the Quick Reply window.
    If any suggestion resolves your issue, please use the Thread Tools dropdown above first post and mark as Solved!

    Debug!Debug!Debug! http://www.cpearson.com/excel/debug.htm

  3. #3
    stockers is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    4
    Hi June, thanks for your response.

    I'm not quite sure i follow though, i'm not super good with Access, Just self taught. Are you able to expand a bit more?

    I have the query laid out, i just need to work out referencing the combobox value with the field in the query.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    41,130
    What do you not understand - how to set up multi-column combobox or how to reference the combobox columns? Or how to build query pulling in related data for report? A combobox is useless on a report.
    To provide db: Make copy, remove confidential data, run compact & repair, zip w/Windows Compression if over 500KB (2MB zip allowed), attach to post. Attachment Manager is below the Advanced post editor window, click Go Advanced below the Quick Reply window.
    If any suggestion resolves your issue, please use the Thread Tools dropdown above first post and mark as Solved!

    Debug!Debug!Debug! http://www.cpearson.com/excel/debug.htm

  5. #5
    stockers is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    4
    Quote Originally Posted by June7 View Post
    What do you not understand - how to set up multi-column combobox or how to reference the combobox columns? Or how to build query pulling in related data for report? A combobox is useless on a report.
    Hi June7

    I don't want a multi-column combobox or a combobox on the report.

    I have a combobox on a form which is Row Source Type: Field List and Row Source: tblmemberdetails

    When the combobox value is selected and the relevant button is pushed I want a report that pulls the Name, Surname and Member Number (also within tblmemberdetails) of all the records where the value in the field that was selected in the form combobox equals true/yes.

    I know how to build a query that can pull that data using filtering one yes/no field however give that there's 50+ fields, i don't want to create that many queries, I just want one that will only filter the field selected in the combobox.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    41,130
    You have 50+ yes/no fields? Sounds like non-normalized structure.

    VBA code to construct the criteria for the WHERE CONDITION argument of OpenReport would be like:

    DoCmd.OpenReport "report name", , , "[" & Me.comboboxname & "]" & "= True"

    The & "= True" probably isn't really necessary as long as the field selected is a Yes/No type.

    Now applying this criteria to the form to display records meeting the criteria can be done by applying to the form Filter property.

    Me.FilterOn = False
    Me.Filter = "[" & Me.combobox & "]"
    Me.FilterOn = True

    Advise not to use reserved words as names for anything - name is a reserved word. Also, avoid spaces and punctuation/special characters (underscore only exception) in names.
    To provide db: Make copy, remove confidential data, run compact & repair, zip w/Windows Compression if over 500KB (2MB zip allowed), attach to post. Attachment Manager is below the Advanced post editor window, click Go Advanced below the Quick Reply window.
    If any suggestion resolves your issue, please use the Thread Tools dropdown above first post and mark as Solved!

    Debug!Debug!Debug! http://www.cpearson.com/excel/debug.htm

  7. #7
    stockers is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    4
    Thank you, that's got it

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    41,130
    Glad it's working. Would have saved us both a lot of headache if I hadn't rushed through reading the original post.
    To provide db: Make copy, remove confidential data, run compact & repair, zip w/Windows Compression if over 500KB (2MB zip allowed), attach to post. Attachment Manager is below the Advanced post editor window, click Go Advanced below the Quick Reply window.
    If any suggestion resolves your issue, please use the Thread Tools dropdown above first post and mark as Solved!

    Debug!Debug!Debug! http://www.cpearson.com/excel/debug.htm

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

Similar Threads

  1. Replies: 9
    Last Post: 08-19-2014, 11:41 AM
  2. Replies: 3
    Last Post: 05-21-2014, 09:15 AM
  3. Replies: 9
    Last Post: 07-31-2012, 10:30 AM
  4. Replies: 7
    Last Post: 03-03-2010, 10:06 AM
  5. Replies: 5
    Last Post: 10-08-2009, 04:15 AM

Posting Permissions

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