Results 1 to 5 of 5
  1. #1
    keiath is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    162

    Auto populate a subform

    Hi Guys



    I have this code

    Private Sub CboStock_Change()
    Me.TxtProductD.Value = Me.CboStock.Column(1)
    Me.TxtPackQ.Value = Me.CboStock.Column(2)
    Me.TxtPrice.Value = Me.CboStock.Column(3)
    Me.TxtVAT_.Value = Me.CboStock.Column(4)
    End Sub

    and the table query:=
    SELECT [Stock Codes].[Product Code], [Stock Codes].[Product Description], [Stock Codes].[Pack Size], [Stock Codes].[Sell Price]
    FROM [Stock Codes];

    When I select the product code (CboStock), the product description (Me.TxtProductD.Value = Me.CboStock.Column(1)) and pack size (Me.TxtPackQ.Value = Me.CboStock.Column(2)) auto populate but the last two the price and VAT are not populating, Any ideas why?

    Thanks

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    You have four Fields in the Combobox, but you're using

    Me.CboStock.Column(X)

    where X is 1-4. The index is Zero-based, meaning it starts with zero, so with 4 Fields it should be 0-3.

    Linq ;0)>

  3. #3
    keiath is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    162
    0 is actually the column for the stock code, hence the reason the first two 1 and 2 are showing the correct information

  4. #4
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Two things...

    First, make sure you "Column Count" property is set correctly on your combobox. It should be set to 4. You need all four fields from your query to be in your combobox. Just having them in the row source itself doesn't do the job. If you need to hide any columns, go to the "Column Widths" property and set their column widths to 0".

    Secondly, Linq is right. The "Column" property is a base 0 array. The first column (Product Code), is the column 0. Product Description is column 1... etc.
    So, "Me.TxtVAT_.Value = Me.CboStock.Column(4)" can't possibly be correct because you don't have a 5th column in your combobox rowsource.

  5. #5
    keiath is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    162
    Hi Sorry meant to say thanks that solved the problem

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

Similar Threads

  1. Auto populate
    By Rabastan in forum Programming
    Replies: 5
    Last Post: 01-25-2014, 10:35 AM
  2. Auto populate tbl
    By fodzilla in forum Access
    Replies: 3
    Last Post: 06-15-2012, 05:03 PM
  3. Replies: 3
    Last Post: 10-03-2011, 02:33 PM
  4. Replies: 12
    Last Post: 08-30-2011, 03:36 PM
  5. Auto Populate
    By co_sportsguy in forum Access
    Replies: 3
    Last Post: 09-01-2010, 01:22 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