Results 1 to 8 of 8
  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 offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    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.
    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
    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 offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    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.
    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
    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 offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    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.
    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.

  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 offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Glad it's working. Would have saved us both a lot of headache if I hadn't rushed through reading the original post.
    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. Replies: 9
    Last Post: 08-19-2014, 12:41 PM
  2. Replies: 3
    Last Post: 05-21-2014, 10:15 AM
  3. Replies: 9
    Last Post: 07-31-2012, 11:30 AM
  4. Replies: 7
    Last Post: 03-03-2010, 11:06 AM
  5. Replies: 5
    Last Post: 10-08-2009, 05: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
  •  
Other Forums: Microsoft Office Forums