Results 1 to 6 of 6
  1. #1
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276

    Auto Fill by Combo Box

    I have 2 Combo boxes on Admin Purchase Form in the samele database.


    CSH Price & STX Price which I want to use to fill the info in the respected fields when they are selected.

    example # 1.
    When I use combo box CSH Price and select "Carton Waste" it should fill the values Carton Waste in Description and "Rs. 6.30" in Price

    example # .
    When I use combo box STX Price and select "Carton Waste" it should fill the values Carton Waste in Description and "Rs. 6.30" in Price and "18.00%" in GST

    Can someone guide me how to do this, I am totally helpless to resolve this issue.
    I have very very basic knowledge on VB

    Thanks
    aamer

    Sample DB.zip

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Why are you updating two fields? Can you update one field with a key value that relates to the other fields?

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Show the RowSource SQL of the two comboboxes. Is it multi-column? Are there columns for ID, Description, Price, GST?

    If you want to save the related info such as price that will require code. I use only VBA. So in the AfterUpdate event of combobox, something like:

    Me!Price = Me.comboboxname.Column(x)

    Column index begins with 0 so if price is in column 3, the index is 2.

    ItsMe has good point. Could just save the ID and not the related info.
    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.

  4. #4
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    June, Thx for reply.
    let me explain.
    by selecting combo box I want to update the following fields
    Description
    Price
    GST
    Please see the sample I have attached.

    thx

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    The way your database is set up, there is no need to save any company info in Purchases. Just save the ItemSr value as foreign key. The company is connected to the item by association in the Items table. However, right now you are saving the item description as primary/foreign key. I recommend using ItemSr as primary/foreign key. Then there is no reason to store company name in Purchases and also no need to use company name in the Master/Child links for subform. (BTW, fieldname CompanyName is misspelled in Company table).

    Again, instead of saving PriceList Description as primary/foreign key, use the PriceList SerialID. There is no need to save the Description, GST because they are associated with the SerialID and can always be retrieved in query. However, I now understand why you want to save price because each item has two possible prices.

    With these adjustments in relationships, no code to save data is needed.

    Textboxes can display the data from the combobox columns with expression:
    =[Combo463].[Column](x)
    Column index begins with 0 so data in column 2 is index 1.

    I just noticed there are two comboboxes and a textbox bound to the same field - Purchase Price. Entry into any will change Purchase Price saved.
    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.

  6. #6
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Thx june for your help.
    I needed the info to go in the purchase table.

    I used the following and got the desired result.

    Private Sub Combo464_AfterUpdate()
    Me.[Purchase Description] = Me.Combo464.Column(0)
    Me.[Purchase Price] = Me.Combo464.Column(1)
    Me.[Purchase Sales Tax] = Me.Combo464.Column(2)
    Me.Requery
    End Sub



    thx again
    regards
    aamer

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

Similar Threads

  1. Replies: 3
    Last Post: 06-09-2013, 05:35 PM
  2. Replies: 5
    Last Post: 11-09-2012, 04:18 PM
  3. Combo Box auto fill and update table
    By memmons in forum Access
    Replies: 4
    Last Post: 09-27-2012, 11:58 AM
  4. auto fill text box from dependent combo box
    By tommyried in forum Access
    Replies: 6
    Last Post: 06-17-2012, 03:55 PM
  5. Creating a auto fill from a combo box
    By Trina76 in forum Forms
    Replies: 4
    Last Post: 02-07-2012, 02: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