By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,993 Members | 1,947 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,993 IT Pros & Developers. It's quick & easy.

Insert Into with Select Statement Does Work

P: 5
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.

Expand|Select|Wrap|Line Numbers
  1. Dim con As Object
  2. Dim rs As ADODB.Recordset
  3. Dim strSql As String
  4.  
  5. Set con = Application.CurrentProject.Connection
  6.  Set rs = New ADODB.Recordset
  7.  
  8.  
  9. strSql = "INSERT INTO InvoiceDetails " & _
  10.              "(fkInvoiceID, InvD_Employee, Inv_Description) " & _
  11.              "SELECT CDO_Invoice.InvoiceNumber, CDOActivity.EmployeeID, " & _
  12.              "CDOActivity.Description " & _
  13.              "FROM CDO_Invoice, CDOActivity " & _
  14.              "WHERE CDOActivity.DateofActivity = " & Me.txtStartDate & " " & _
  15.              "AND CDOActivity.fkCDO = " & Me.cboCDO.Value & " ; "
  16.  
  17.         MsgBox strSql
  18.  
  19.     rs.Open strSql, con, 1    ' 1 = adOpenKeyset
Jul 28 '07 #1
Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,560
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.
Jul 29 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.