473,511 Members | 14,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DoCmd.RunSQL vs rs.Open

Hello,

I am running an sql statement that INSERTS INTO a table. If I run the
query using docmd.runSQL, it works fine - new records are added to the
table and duplicate records are disregared ( I use DoCmd.SetWarnings
False so the users don't see the warning about duplicate records).

If I run the same query using this:

rs.Open qryPolePosition1, CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

I get a message saying The changes I request can't be made because
they'll cause duplicate values...

Even if I wanted to live with the warning message, the new records are
not being added to the table. It seems like as soon as the error
occurs, processing stops.

I can use the docmd.runSQL but it is noticeably slower than the
rs.open method.

I'm including my sql statement. I was wondering if anyone could tell
me why this query works one way and not the other.

Thanks, Andy
qryPolePosition1 = "INSERT INTO tblPoleMaintDetails " & _
"(fldPoleDataIDfk, fldPolePos, fldPoleCode,
fldPoleStatus, fldImmAtt) " & _
"SELECT tblPoleData.fldId, '1'," & _
"tblPoleData.Code1, tblPoleData.Status1,
tblPoleData.ImmAttn1 " & _
"FROM tblPoleData " & _
"WHERE (tblPoleData.PoleSize1 Is Not Null) OR
(tblPoleData.Code1 " & _
"Is Not Null) OR (tblPoleData.Status1 Is Not
Null) OR (tblPoleData.ImmAttn1 <>0)"
Nov 12 '05 #1
0 1918

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
8222
by: Jim | last post by:
I am using Access 97 on a PC running Windows NT 4.0 SP6a. I have some code (shown below) intended to add a set of records to one table (tblGradeProps) when a new record is created in another...
4
10173
by: Rotsj | last post by:
Hi, i try to execute an update query from within a form, but i get the message: run time error '3144'. Syntax error on the update statement when i try something like this: DoCmd.RunSQL...
3
3447
by: Pathfinder | last post by:
Hi All I am trying to run the below but I receive the following error "runsql action requires an argument consisting of an SQL statment" Dim MySQL$ MySQL$ = "Select * from mytablename"...
7
4269
by: Richard Hollenbeck | last post by:
Help! I don't know why this isn't working: Private Sub Combo9_Change() Dim UsersCourseSelection As String UsersCourseSelection = Me("Combo9").Value Combo13.Visible = True 'the following...
8
11202
by: RC | last post by:
In my Access 2002 form, I have a combo box and on the AfterUpdate event I use DoCmd.RunSQL ("UPDATE .... to update records in a table. When it starts to run I get a message "You are about to...
6
68519
by: David | last post by:
I am trying to insert an employee number into the EmpNbr field in my main table from a form where I add a new employee to my employee table. I was hoping this command would work, but it isn't. ...
2
5694
by: ben | last post by:
I have the following code in a VBA module: DoCmd.RunSql "Update tData Set sd = Log(Strike/Price) where symbol = '" & symbol & "'" This statement worked fine, and was using the built in math...
3
2557
by: jl2886 | last post by:
Hello. I have two questions: Private Sub Form_Load() Dim assID As Long assID = DMax("CLng(Right(,3))", "Master_Log") Me.LSI_Case_Number = Month(Date) & Format(Year(Date), "yy") & "-" &...
1
3049
by: natural | last post by:
Good Afternoon I have an option grou[ and on the after update i would like to provide the user with a msgbox, and then action placed my docmd.setwarnings false everywhere, but i still get my...
0
7252
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,...
0
7153
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...
0
7371
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,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5077
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
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...
0
1583
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 ...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.