Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004

    Unanswered: AfterUpdate problem

    I have a form that contains a combo box. The combo box has about 30 different values, text values. Each one of those has a different impact on 10 or so different fields. Those 10 or so fields either contain a -1 or a 1.

    What I would like to happen is that when the person who uses this utility picks a value in the combo box, the 10 or so fields are automatically updated with the values that correspond to the selection in the combo box.

    So "Spill" would have say -1, 1, 1, 1, 1, -1, etc.

    This is the code that I am trying to use. I have used this before in another application with good results, no problems at all. However, when I use it now, the form does not show any change at all. The fields that I want to update don't update at all. The sql is all on one line (the forum will likely break that) and if run in a window gets the result just fine.

    Private Sub Charge_Type_AfterUpdate()

    Dim db As dao.Database
    Dim rst As dao.Recordset
    Dim sales1 As Long
    Dim cs1 As Long
    Dim purch1 As Long
    Dim plan1 As Long
    Dim comp1 As Long
    Dim prod1 As Long
    Dim r_d1 As Long
    Dim qc1 As Long
    Dim lab1 As Long
    Dim whouse1 As Long
    Dim fina1 As Long
    Dim sqlstr As String

    Set db = CurrentDb()

    sqlstr = "SELECT sales, cs, purchasing, planning, compounding, production, r_d, qc, lab, whouse, finance FROM [Charge_Main] WHERE charge_type = '" & Me![Charge_Type] & "'"

    Set rst = db.OpenRecordset(sqlstr)
    If Not rst.EOF Then
    Me![sales1] = rst![sales]
    Me![cs1] = rst![cs]
    Me![purch1] = rst![purchasing]
    Me![plan1] = rst![planning]
    Me![comp1] = rst![compounding]
    Me![prod1] = rst![production]
    Me![r_d1] = rst![r_d]
    Me![qc1] = rst![qc]
    Me![lab1] = rst![lab]
    Me![whouse1] = rst![whouse]
    Me![fina1] = rst![finance]

    End If

    End Sub

  2. #2
    Join Date
    Apr 2004
    metro Detroit
    Is Charge_Type a combo box? If so try putting your code in the Change event rather than the After Update event.

  3. #3
    Join Date
    Mar 2004
    Well this is embarrasing. This worked just fine. The problem was the field that was storing the value I needed was in fact a combo box, and the first column was a number, and I was looking for the text description which was in the 2nd column, but due to the justification, I was only seeing the description.

    So once I fixed that it works like a charm. I should have eaten lunch earlier.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts