Consulting

Results 1 to 3 of 3

Thread: Using Comboboxes to Update a Worksheet??

  1. #1

    Using Comboboxes to Update a Worksheet??

    I have a userform with a listbox, comboboxes, text boxes, and commandbutton to update the current record in the worksheet; eg: Suppliers, Materials, Units, Qty & Price. The Suppliers and Units comboboxes are filled once when the form is initialized. On Listbox_click() the materials combobox is updated with respective options for the current record from another worksheet. The Price textbox is updated on the Materials combobox_change() event. Qty is user specified.

    Does anyone know why the following wont save the current values of the comboboxes to the worksheet?

    <Reposted Code>[vba]
    Private Sub btnSave_Click()

    Dim thisIdx As Long

    Dim celSuppliers as String
    Dim celProducts as String
    Dim celUnits as String
    Dim celQty as String
    Dim celPrice as String

    celSuppliers = "E"
    celProducts = "F"
    celUnits = "G"
    celQty = "H"
    celPrice = "I"

    Application.ScreenUpdating = False

    thisIdx = ListBox1.ListIndex + 2

    With Worksheets(shtCabinetKey) 'shtCabinetKey = "CabinetKey" is Public

    .Range(celSuppliers & CStr(thisIdx)).Select
    .Range(celSuppliers & CStr(thisIdx)).Value = cboSuppliers.Value

    .Range(celProducts & CStr(thisIdx)).Select
    .Range(celProducts & CStr(thisIdx)).Value = cboMaterials.Value

    .Range(celUnits & CStr(thisIdx)).Select
    .Range(celUnits & CStr(thisIdx)).Value = cboUnits.Value

    .Range(celQty & CStr(thisIdx)).Select
    .Range(celQty & CStr(thisIdx)).Value = txtQty.Value

    .Range(celPrice & CStr(thisIdx)).Select
    .Range(celPrice & CStr(thisIdx)).Value = txtPrice.Value

    End With

    Application.ScreenUpdating = True

    end sub
    [/vba]
    Last edited by websmythe; 04-23-2008 at 01:05 PM.
    When the going gets tough, the tough get weird

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    websmythe, we have no way of knowing what celPrice etc. is, ideally post the whole code you are using as it is only your assumption that its that portion of code that isn't giving you the results.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    Sorry. As it was the Range() function I thougtht it would be assumed what it was. Maybe it is another event somewhere causing the problem. Thot I'd covered for that.

    <UPDATE>
    Ya, just trapped for any other events, and sure enough it seems like a hidden click event or something was repopulating the list prior to writing the value to the record.

    Thanx.
    Last edited by websmythe; 04-23-2008 at 01:31 PM.
    When the going gets tough, the tough get weird

Posting Permissions

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