Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102

    Multiple choice in a form which has the multiple choice data from a table.

    Hello all,




    I have a rather big problem, I have a table: "tbl20", a form: "foOfferte" and a report: "repOfferte". "foOfferte" is responsible for inserting the data into the report. This means that the user selects the data to be included in the report. I have managed all this, but now I have a problem. I would like the user to have a multiple choice selection at position 20. The selection should come from the table "tbl20".


    I have made a small sketch of how it should look:


    Click image for larger version. 

Name:	Sketch.png 
Views:	44 
Size:	13.3 KB 
ID:	48819

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,653
    When you say multiple choice do you mean the user can select one from multiple choices or do you mean the user can make several choices from the form?

    Is this Multi-User? If you have yes/no fields in the table you need to consider collisions where 2 people may be selecting choices at the same time.
    I would be more inclined to use a list box.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  3. #3
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    229
    Add a yes/no-field to tbl20 and make a continuous form showing both the values and the yes/no-field.
    In your report you can select all records from the tblOfferte that have a checked value.

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,653
    Quote Originally Posted by xps35 View Post
    Add a yes/no-field to tbl20 and make a continuous form showing both the values and the yes/no-field.
    In your report you can select all records from the tblOfferte that have a checked value.
    Except if there is more than 1 user. When using the main table in that scenario, 2 people may be checking off items and you will get inaccurate results.
    I would use an unbound listbox for the selections.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #5
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by Akchayan View Post
    Hello all,


    I have a rather big problem, I have a table: "tbl20", a form: "foOfferte" and a report: "repOfferte". "foOfferte" is responsible for inserting the data into the report. This means that the user selects the data to be included in the report. I have managed all this, but now I have a problem. I would like the user to have a multiple choice selection at position 20. The selection should come from the table "tbl20".


    I have made a small sketch of how it should look:


    Click image for larger version. 

Name:	Sketch.png 
Views:	44 
Size:	13.3 KB 
ID:	48819
    Or is it possible that I simply create a listbox in which all values of the table "tbl20" are, and when the user (there is always only one user, so there are never several users online) double-clicks on a value in the listbox, it directly takes over this value into a text field?

  6. #6
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    229
    Quote Originally Posted by Akchayan View Post
    Or is it possible that I simply create a listbox in which all values of the table "tbl20" are, and when the user (there is always only one user, so there are never several users online) double-clicks on a value in the listbox, it directly takes over this value into a text field?
    What is wrong with the proposal I did? As others said, it will work when there is one user. Your form will look like your design. The only difference is that you don't see rounds but squares.
    I do not understand your solution. You double-click a listitem and copy it to a text field (I don't see one on your form). And then? How do you use that as a criterion for your report?
    Groeten,

    Peter

  7. #7
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,653
    You didn't answer my question re: Multiple choice.

    tbl20 and Position20 do not give us any insight as to what you want to happen. Could you describe your database and give us some context as to what you want to achieve?
    How do the selection or selections work in relation to your report?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  8. #8
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,653
    What is wrong with the proposal I did? As others said, it will work when there is one user.
    Nothing wrong with it. The question is whether it is more efficient. That method involves writing to the table and deleting from the table repeatedly.
    An unbound list box , whether single selection or multi-select, doesn't carry that overhead as slight as it may be. It also precludes the need for a re-write should there be a need for multiple users in the future.

    We can't really suggest a more detailed solution without the OP responding to our questions.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  9. #9
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by xps35 View Post
    Add a yes/no-field to tbl20 and make a continuous form showing both the values and the yes/no-field.
    In your report you can select all records from the tblOfferte that have a checked value.
    I don't quite understand how to implement this. Could you explain it further? Thank you very much!

  10. #10
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    229
    If you could post an example of your database, I think I can make a demo.
    Groeten,

    Peter

  11. #11
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    This is my table with the values:
    Click image for larger version. 

Name:	Screenshot 2022-10-04 140823.png 
Views:	22 
Size:	39.0 KB 
ID:	48846
    This is my form in which the user is then supposed to click yes or no:
    Click image for larger version. 

Name:	Screenshot 2022-10-04 140931.png 
Views:	22 
Size:	39.0 KB 
ID:	48847
    My report is a normal report in which the values must be filled in for which Yes is clicked.

  12. #12
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,653
    Here's an example how to do it with an unbound listbox
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  13. #13
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    how exactly does it work, so what is the process?
    First I select the individual data in the list and press the "command2" button, but then the report does not open at all.

  14. #14
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,653
    Not sure if it is an issue that I use 32 bit and your 64 bit but doubt it. May also be that your language uses different delimiter ( an ; instead of , )

    code is rather simple.

    my function for iterating through the listbox returns a string such as 1,2,4,6. these being the 0 column of the listbox, the primary key of the table.
    Code:
    Public Function getLBX(lbx As ListBox, Optional intColumn As Variant = 0, Optional Seperator As String = ",", _
                           Optional delim As Variant = Null) As String
    
    'Iterates thru the multiselect listbox and constructs an array of the selected items
    'Arguments:
    'Lbx is Listbox Object ie.Me.MyListbox
    'intColumn is the column # to be returned
    'Seperator is the character seperating items in array returned
    'Delim is optional delimiter to be return in array ie. #1/1/2001#,#12/25/2015#
    
        Dim strlist As String
        Dim varSelected As Variant
    
        'On Error GoTo getLBX_Error
    
        If lbx.ItemsSelected.Count = 0 Then
            'MsgBox "Nothing selected"
        Else
    
            For Each varSelected In lbx.ItemsSelected
    
                If Nz(lbx.Column(intColumn, (varSelected)), "") <> "" Then
    
                    strlist = strlist & delim & lbx.Column(intColumn, (varSelected)) & delim & Seperator
    
                Else
    
                    strlist = strlist
    
                End If
    
            Next varSelected
    
            If Nz(strlist, "") <> "" Then
    
                strlist = Left$(strlist, Len(strlist) - 1)  'remove trailing comma
    
            End If
        End If
    
        getLBX = strlist
    
        On Error GoTo 0
        Exit Function
    
    getLBX_Error:
    
        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure getLBX of Module modLBX"
    
    End Function
    the code calling the report is

    Code:
    Private Sub Command2_Click()
    
    If Me.List0.ItemsSelected.Count = 0 Then MsgBox "Nothing Selected": Exit Sub
    
    DoCmd.OpenReport "Report1", acViewReport, , "PosID in(" & getLBX(Me.List0) & ")"
    
    End Sub
    the relevant part is the where argument of the open report method.

    Code:
     "PosID in(" & getLBX(Me.List0) & ")"
    this would resolve to something like "PosID in (1,2,4,5)"
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  15. #15
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    229
    Quote Originally Posted by Akchayan View Post
    how exactly does it work, so what is the process?
    First I select the individual data in the list and press the "command2" button, but then the report does not open at all.
    I cannot tell how it "exactly" works if you do not provide sufficient information. What is the name and the structure of the table behind the report. What is the code behind command2?
    Groeten,

    Peter

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to output data from multiple choice
    By oppoiste0731 in forum Access
    Replies: 3
    Last Post: 12-20-2017, 06:36 PM
  2. Replies: 7
    Last Post: 09-14-2017, 02:24 AM
  3. Replies: 0
    Last Post: 03-19-2017, 01:29 PM
  4. create a table for a multiple choice question
    By Winter1 in forum Database Design
    Replies: 4
    Last Post: 03-31-2015, 10:18 AM
  5. Replies: 7
    Last Post: 10-16-2012, 06:43 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