Results 1 to 11 of 11
  1. #1
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149

    Post combo show incorrect data

    I use the Property Sheet to set a combobox, and it shows correct data as below.
    Click image for larger version. 

Name:	p1.png 
Views:	28 
Size:	8.7 KB 
ID:	50274Click image for larger version. 

Name:	p2.png 
Views:	27 
Size:	9.8 KB 
ID:	50275Click image for larger version. 

Name:	p3.png 
Views:	27 
Size:	12.2 KB 
ID:	50276

    but when I using the same coding as below
    Code:
    With Me.Combo278
      .RowSource = "SELECT VeCode,VeId,VeEName FROM Vendor ORDER BY VeCode"
      .ColumnCount = 3
      .ColumnWidths = "1;0.6;1.5"
    End With
    it shows data as below
    Click image for larger version. 

Name:	p4.png 
Views:	27 
Size:	11.6 KB 
ID:	50277

    What is my problem? thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Why would you have VeCode as first column and save that value instead of Veid? If you don't use Veid, why have it? Users shouldn't even need to see this field.

    Why use VBA to set these properties?


    .ColumnWidths = "1"";0.6"";1.5"""

    or

    .ColumnWidths = "1 in;0.6 in;1.5 in"
    Last edited by June7; 05-26-2023 at 08:48 AM.
    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
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    But it is not the same. In your first image it is 1”;etc, in your code it is 1; etc

    Try ColumnWidths = "1””;0.6””;1.5"””

    Unable to test as in the uk we use cm

    widths are actually stored as twips - there are 1440 twips to an inch so what you are seeing is a format based on your windows setting for units of measurement

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You can include the unit of measure in the settings as
    "1 cm;0.6 cm;1.5 cm" or "1 in;0.6 in;1.5 in" . A value of 0 will hide a column. Or don't provide settings and the control width will be divided by the number of columns.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149
    thanks. it work now. the combo show 3 columns in 1in, 0.6in and 1.5in.

    then i set the combo's width to 2.5in, it shows only part of the third column.

    how to set if the combo width is less then the total length of the 3 columns? so that I can see all the 3 columns?

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    Quote Originally Posted by uoghk View Post
    thanks. it work now. the combo show 3 columns in 1in, 0.6in and 1.5in.

    then i set the combo's width to 2.5in, it shows only part of the third column.

    how to set if the combo width is less then the total length of the 3 columns? so that I can see all the 3 columns?
    Sum up each column width and adjust the control width.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    You might find the web helps with a lot of your questions - see this link
    https://learn.microsoft.com/en-us/of...obox.listwidth

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Did not address my question in post #2.

    Your combobox is set to save VeCode not VeID which means VeID is not serving purpose of primary/foreign key and is not needed in combobox RowSource. Which field is set as primary key in Vendor table?
    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
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    how to set if the combo width is less then the total length of the 3 columns?
    Set the list width to just a bit more than the sum of the column widths rather than the control width?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149
    Thanks Micron.
    You solve my problem.

  11. #11
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Glad I could help!
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Combo box incorrect format
    By RasterImage in forum SharePoint
    Replies: 3
    Last Post: 08-10-2021, 10:18 AM
  2. Replies: 3
    Last Post: 11-16-2016, 12:40 PM
  3. Replies: 4
    Last Post: 10-06-2012, 11:57 AM
  4. Replies: 4
    Last Post: 11-24-2011, 10:26 PM
  5. Incorrect Values Populating My Combo Boxes
    By charlyzaingel in forum Forms
    Replies: 19
    Last Post: 06-23-2011, 10:17 AM

Tags for this Thread

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