Results 1 to 12 of 12
  1. #1
    habiler is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2017
    Posts
    13

    How To Fill A Combobox With The Value Of A Group Options Control

    I have a tbl Afd_Serv with 2 columns named directorat (number) and txtdescrip.


    How can i fill the combobox "cboServices" with a value (number) given in the group options "fraDep" (Select case 1 to 4) with the same value of the value in the colum directorat from tbl Afd_Serv.




    I written following code :
    Code:
    Private Sub cboServices_click()
    Dim strSQL As String
    Debug.Print "Me.fraDep CboServices 1:"; Me.cboServices.Value
    'strSQL = "select * from Afd where Directorat = " & Me.fraDep & ";"
    ' ou si cle est du String:
    strSQL = "select [Omschrijving frans] from Afd_Serv where Directorat = " & Me.cboServices & ""
     Debug.Print "Me.fraDep CboServices 2:"; Me.cboServices.Value
    Me.cboServices.RowSource = strSQL
    
    
    End Sub



    Code:
    Private Sub fraDep_AfterUpdate()
    .......
    
    
    Select Case fraDep.Value
    Case 1
    	
    		strDep = "'*'"
    		libelleDep = "All"
    		cboServices.Visible = False
    		
    		
     Case 2
    		strDep = "'CEO'"
    		libelleDep = "CEO"
    		cboServices.Visible = True
    		cboServices.Value = 5
    		cboServices.Requery
    		
     Case 3
    		strDep = "'DGA'"
    		libelleDep = "DGA"
    		cboServices.Visible = True
    		cboServices.Value = 6
    		cboServices.Requery
     Case 4
    		strDep = "'DGO'"
    		libelleDep = "DGO"
     Case 5
    		strDep = "'DGS'"
    		libelleDep = "DGS"
     Case Else
    		strDep = "'Other'"
    		libelleDep = "Other"
     End Select
    ........

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,648
    This code will not 'fill the combobox with a value', it sets the combobox RowSource property.

    A combobox RowSource cannot be dependent on itself. Reference the frame control instead of the combobox.

    Then requery the combobox: Me.cboServices.Requery

    I would use GotFocus instead of Click event.
    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
    habiler is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2017
    Posts
    13
    I 've modified the code and now I have only digits as result.


    in fact the value of "" & cboServices & "" and not the value of [Omschrijving frans]




    Code:
    Private Sub cboServices_GotFocus()
    Dim strSQL As String
    Debug.Print "Me.fraDep CboServices 1:"; Me.cboServices.Value
    'strSQL = "select * from Afd where Directorat = " & Me.fraDep & ";"
    ' ou si cle est du String:
    strSQL = "select [Omschrijving frans] from Afd_Serv where Directorat = "" & cboServices & "" "
    Debug.Print "strSQL 2:"; strSQL
    
    
    Me.cboServices.Requery
    
    
    End Sub
    [QUOTE=habiler;435906]
    Attached Thumbnails Attached Thumbnails Capture1.PNG  

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Try setting linked column (colonne liée) to 0 instead of 1.

    Essayez de définir la colonne liée sur 0 au lieu de 1.

  5. #5
    habiler is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2017
    Posts
    13
    ok BUT IT STARTS AT LINE 5 OR 6 5 of column directorat. (number attrbuted at cboservices).

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    I suggest you post a copy of the database with enough records to show the form and combobox (in zip format.)
    Also show us a sample(just info on paper) of what you expect using a data/record you would have in that combo.

  7. #7
    habiler is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2017
    Posts
    13
    Here I send you a copy of my Database
    Habiler

    Leaves1_12.zip

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,648
    The db structure has serious issues. Tables are not linked on key fields. Form RecordSource is too complicated. A form normally does data entry/edit for 1 table. Trying to open form and get error [Leave] is not recognized as a valid field name.

    Advise not to use spaces nor punctuation/special characters in naming convention.
    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.

  9. #9
    habiler is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2017
    Posts
    13
    Ok but how can shows gra^hics on screen the? Via a report?

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,648
    The graph RowSource has nothing to do with form RecordSource. They are fine on form or use a report. Actually why does form even have RecordSource? There are no bound controls.

    GraphLeave RowSource references field [Leave] which is not in that data source, hence the error I encounter when opening form.
    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.

  11. #11
    habiler is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2017
    Posts
    13
    Here a simplified version of my DB.


    Leaves1_121.zip

  12. #12
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    I agree with June that your database structure has issues. In order to understand your database and its tables and relationships, we need some description of the business and its rules. Also, since we are not dealing with English, a clear description is key to getting focused responses.

    Relationships are a representation of the business rules, so knowing more about the business is essential.

    You can write a 4 or 5 line overview of the business in your native language and then use Google translate to provide the English translation.

    Good luck.

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

Similar Threads

  1. Replies: 2
    Last Post: 09-17-2014, 09:35 AM
  2. Replies: 3
    Last Post: 07-14-2013, 09:16 PM
  3. ComboBox options
    By dylcon in forum Forms
    Replies: 20
    Last Post: 06-07-2013, 09:26 AM
  4. Replies: 9
    Last Post: 05-29-2012, 11:03 AM
  5. ComboBox to ComboBox automatic fill
    By vbjohn in forum Access
    Replies: 2
    Last Post: 08-18-2011, 01:35 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