Insert Into with Select Statement Does Work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Newbie in ChiTown
    New Member
    • Oct 2006
    • 5

    #1

    Insert Into with Select Statement Does Work

    Here's my code:

    I am using MS Access and I am trying to update a table (InvoiceDetails ) with data input by the user on a form. However, it does not update nor does it give me an error message. Code listed below.

    Also, can you recommend a book on SQL.

    Thanks.

    Code:
    Dim con As Object
    Dim rs As ADODB.Recordset
    Dim strSql As String
            
    Set con = Application.CurrentProject.Connection
     Set rs = New ADODB.Recordset
        
          
    strSql = "INSERT INTO InvoiceDetails " & _
                 "(fkInvoiceID, InvD_Employee, Inv_Description) " & _
                 "SELECT CDO_Invoice.InvoiceNumber, CDOActivity.EmployeeID, " & _
                 "CDOActivity.Description " & _
                 "FROM CDO_Invoice, CDOActivity " & _
                 "WHERE CDOActivity.DateofActivity = " & Me.txtStartDate & " " & _
                 "AND CDOActivity.fkCDO = " & Me.cboCDO.Value & " ; "
                
            MsgBox strSql
        
        rs.Open strSql, con, 1    ' 1 = adOpenKeyset
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    This is not a simple code-fixing service (even if it were a LOT more background information would be required before starting). Try posting the resultant SQL as a start (in CODE tags this time please) and we'll see if anything obvious jumps out.
    I'm afraid I don't know of a book. I learnt by playing with it and referring to the help system when necessary.

    Comment

    Working...