Consulting

Results 1 to 3 of 3

Thread: Solved: Listbox Loop in Query update

  1. #1
    VBAX Tutor
    Joined
    Sep 2007
    Posts
    265
    Location

    Solved: Listbox Loop in Query update

    Hi there
    Hope you are doing good.

    Do me a favor, if I want to update some records on all selected list in a listbox

    With the following syntax, I get stuck with error message - Too few parameter

    [VBA]Private Sub CmdUpdate_Click()
    Dim iloop As Long

    Call Connect 'sub function on connection string

    For iloop = 1 To MyList.ListCount
    If MyList.Selected(iloop - 1) = True Then

    cn.Execute "Update tblPPDC set DateRcvd= Trim(TextBox1.Text) where LRF_No='" & Trim(Me.MyList.List(Me.MyList.ListIndex, 0)) & "'", , adCmdText

    Me.MyList.ListIndex = Me.MyList.ListIndex - 1
    MyList.Selected(iloop - 1) = False
    End If
    Next
    cn.Close
    Set cn = Nothing
    End Sub[/VBA]

    Any kind of suggestion, would be much appreciated it
    Harto

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I suspect this should be in quotes "Trim(TextBox1.Text)"
    Try debug.print the execute statement to see if it looks right.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Tutor
    Joined
    Sep 2007
    Posts
    265
    Location
    Hi Malcom
    Thanks so much, you made my day!

Posting Permissions

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