473,568 Members | 2,850 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert Into with Select Statement Does Work

5 New Member
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
1 3115
NeoPa
32,564 Recognized Expert Moderator MVP
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

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

Similar topics

8
5509
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE, UPDATE, DELETE) which are controlled by a web frontend and the table records are manipulated to control the permissions. Example: The Press...
1
15397
by: shottarum | last post by:
I currently have 2 tables as follows: CREATE TABLE . ( mhan8 int, mhac02 varchar(5), mhmot varchar(5), mhupmj int )
16
16984
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then...
4
5468
by: Chris Kratz | last post by:
Hello all, We have run into what appears to be a problem with rules and subselects in postgres 7.4.1. We have boiled it down to the following test case. If anyone has any thoughts as to why this would be happening, we would appreciate feedback. We have tested on 7.3.4, 7.3.6 and 7.4.1 and all exhibit the same behavior. Test case one...
20
18319
by: Mark Harrison | last post by:
So I have some data that I want to put into a table. If the row already exists (as defined by the primary key), I would like to update the row. Otherwise, I would like to insert the row. I've been doing something like delete from foo where name = 'xx'; insert into foo values('xx',1,2,...);
29
27546
by: pb648174 | last post by:
I have the following basic statements being executed: Create a temp table, #TempPaging Insert Into #TempPaging (Col1, Col2) Select Col1, Col2 From SomeOtherTable Order By Col2, Col1 Select * from #TempPaging I can't provide a reproduceable scenario right now without making this
1
15458
by: cefrancke | last post by:
I'm trying to insert records in a table that has a "no duplicates" index on two columns. The following snippet shows where I started off... INSERT INTO Table_A (ID_A, ID_B) VALUES (334, 2057) However, if these two values exist already as a "key" combination then, the MS Access
8
3495
by: nano2k | last post by:
Hi Shortly, I keep invoices in a table. Occasionally, someone will fire the execution of a stored procedure (SP) that performs several UPDATEs against (potentially) all invoices OLDER than a date that is supplied to the SP as a parameter. The SP is usually a lengthy process (it takes at least 30 mins). The problem is that SQL server 2000...
15
10825
by: dataguy | last post by:
I am trying to insert into a temporary table but only the first n number of rows. I thought I could use the combination of insert into and fect first row command ,but it won't work. Does anyone know why? Any other suggestions other than writing a loop? This is in a db2 sql stored procedure that is called from another db2 sql stored proc.
4
6378
by: ryushinyama | last post by:
I had to do a lot of searching to get this one to work and in doing so I saw a lot of different sites where people were looking for this answer so I thought I would put it up. If you are trying to put data in to a table where you don't want any duplicate data a primary key, unique constraint and all that prevention is the best way to go. ...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.