Wanting to copy the record--I keep getting an error.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jass7869
    New Member
    • Jan 2015
    • 1

    Wanting to copy the record--I keep getting an error.

    Code:
    rivate Sub txtLineItem_Click()
    On Error GoTo Err_Handler
    
        Dim strQry As String, strUName As String, lngFinalIdx As Long
        
        'lngFinalIdx = Me.FinalIdx
        'strUName = GetUserName()
        
        strQry = "insert into Final_Table_Crosstab("
        strQry = strQry & " Org Name, CostCen, Fund, PEC" & vbCrLf
        strQry = strQry & "SELECT Org Name, CostCen, Fund, PEC" & vbCrLf
        strQry = strQry & "from Final_Table_Crosstab where FinalIdx = " & lngFinalIdx & vbCrLf
        
        QuickQry strQry, True
        Me.Requery
    
    
    Exit_Proc:
        Exit Sub
        
    Err_Handler:
        MsgBox "In CopyRecord" & vbCrLf & Err.Number & "--" & Err.Description
        Resume Exit_Proc
    End Sub
    Last edited by Rabbit; Jan 6 '15, 08:47 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • jforbes
    Recognized Expert Top Contributor
    • Aug 2014
    • 1107

    #2
    My first guess is that you need to end you parentheses like this:
    Code:
        strQry = strQry & ") SELECT Org Name, CostCen, Fund, PEC" & vbCrLf
    There may be other problems. A way for you to troubleshoot this is to put a break when you are ready to execute the SQL statement, then ?strQry in the immediate window, so you can copy and paste it into a temporary query or SQL Server Management Studio to see what kind of errors you are getting.

    Comment

    Working...