Results 1 to 5 of 5
  1. #1
    Ron99 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2013
    Posts
    7

    Form Gets Data From Query and Adds It to Table

    I have a form, ContractEntry, that has a combo box, Contractcbo, that the dropdown box is filled with a field, Symbol (text), from a query, MarginsPrices. The selection made is entered into the record using Control Source into the field Contract of the table AllContracts.

    The Row Source for Contractcbo is
    SELECT MarginsPrices.Symbol, [MarginsPrices].[Margin] FROM MarginsPrices;

    What I now need on the same form is for a textbox to be populated with the number, Margin, from the MarginsPrices table. This number then needs to be saved with the rest of the data entered on the ContractEntry form into the table AllContracts. The number Margin changes daily and I want to save it in the record as what it was when I entered the record.

    I tried this
    Private Sub Contractcbo_AfterUpdate()

    Me.Margintextbox = Me.Contractcbo.Column(2)

    End Sub


    but it doesn't work.
    Help!

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538

  3. #3
    Ron99 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2013
    Posts
    7
    With the help of @alansidman I got it to work. But now when I try to add a second text box that gets its' data from the combo box, it won't work correctly for the second text box, BegOXMargtbx.

    The Contractcbo combo box has this row source
    SELECT MarginsPrices.[Symbol], MarginsPrices.[SPAN Req/Init], MarginsPrices.[OE Margin] FROM MarginsPrices;

    Then I have this

    Private Sub Contractcbo_AfterUpdate()

    Me.BegSPMargtbx = Me.Contractcbo.Column(1)
    Me.BegOXMargtbx = Me.Contractcbo.Column(2)

    End Sub


    BegSPMargtbx correctly gets its' data but BegOXMargtbx gets nothing. If I change
    Me.BegOXMargtbx = Me.Contractcbo.Column(2)
    to
    Me.BegOXMargtbx = Me.Contractcbo.Column(1) it gets the data from column 1.

    But when I change it back to column 2 it doesn't work.

  4. #4
    Ron99 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2013
    Posts
    7
    If I change the Column Count on the combo box to 2, even though I don't want the second column to appear in the drop down box, then BegOXMargtbx gets the correct data.

  5. #5
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    In the properties for the combo box, set the column widths to 0; for those columns you don't wish to see. ie. if you have three columns and only wanted to see the third column, then the setting would be 0";0";1.0 for a 1 inch setting of the third column and columns 1 and 2 are hidden.

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

Similar Threads

  1. update query that adds 8.25% taxes
    By alinapotter in forum Queries
    Replies: 2
    Last Post: 04-09-2013, 07:59 AM
  2. Query adds record to table?!?
    By dantejazz in forum Queries
    Replies: 9
    Last Post: 03-11-2012, 08:58 PM
  3. Replies: 6
    Last Post: 02-03-2012, 07:31 PM
  4. Replies: 2
    Last Post: 12-20-2011, 10:09 AM
  5. Clicking on Form Background Adds New Record?
    By swimmermx in forum Forms
    Replies: 3
    Last Post: 08-03-2010, 12:14 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