473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Recordset RunSQL problem, please help.

Hi,

I'd really appreciate some help here people. I am trying to insert some values in a table in another database and not getting the results I am expecting. I am simply trying to insert values via a connection to a recordset and then close the recordset.

However I keep getting a type mismatch on the variable rstMainData.

Please can someone help me? The code is as below.



Private Sub txtGetURN_AfterUpdate()
DoCmd.SetWarnings False
Call ClearAll
Dim wsAccess As Workspace
Dim dbBackEnd As DAO.Database
Dim strSQL As String
Set wsAccess = DBEngine(0)

Set dbBackEnd = wsAccess.OpenDatabase("S:\RLR RMU\033 GI Services\NewParcelsCreated\ParcelsCreated_Data.mdb ", False, True)

MsgBox dbBackEnd.Name

Dim rstMainData As DAO.Recordset
Set rstMainData = dbBackEnd.OpenRecordset("tblMainData", dbOpenTable)

strSQL = "INSERT INTO tblMainDataNew SELECT tblMainData.* FROM "
strSQL = strSQL & rstMainData
strSQL = strSQL & " WHERE (((tblMainData.URN)=[Forms]![frmMainData]!txtGetURN]))"


rstMainData.Close
Set rstMainData = Nothing

wsAccess.Close
Set dbBackEnd = Nothing
DoCmd.SetWarnings True
DoCmd.Requery
Call RequeryLists

End Sub
Dec 10 '07 #1
1 1794
FishVal
2,653 Expert 2GB
Hi, Lazster.

Why pay more. You may append records from/to an external db table without getting connection to it.

to external db
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tblMainDataNew IN 'S:\RLR RMU\033 GIServices\NewParcelsCreated\ParcelsCreated_Data.mdb' SELECT tblMainData.* FROM tblMainData WHERE (((tblMainData.URN)=[Forms]![frmMainData]!txtGetURN]));
  2.  
from external db
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tblMainDataNew SELECT tblMainData.* FROM tblMainData IN 'S:\RLR RMU\033 GIServices\NewParcelsCreated\ParcelsCreated_Data.mdb' WHERE (((tblMainData.URN)=[Forms]![frmMainData]!txtGetURN]));
  2.  
Regards,
Fish
Dec 10 '07 #2

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

Similar topics

1
by: Tom Lee | last post by:
Hi Guys, Firstly thanks for all the help you have providing me... I have another question I was stuck with. Here is a simple code dim strsql as string dim scr as recordset
3
by: -Michelle- | last post by:
Hi Using A2003 on XP I am wondering from the MVP's and others, what is the most efficient way (in terms of time to process) of updating data in a table, using the docmd.RunSQL or Recordset ...
5
by: msprygada | last post by:
I am having a problem with getting a recordset to fill with data in an Access Data Project from a SQL Server database. Here is the code example that is in the Access help files that I can get to...
3
by: RBohannon | last post by:
Suppose I want to add a new record to a table. I could use SQL and DoCmd.RunSQL: '===== Dim strSQL as string ' assume myVars are properly delineated for data types of myFields strSQL =...
1
by: Jason Lepack | last post by:
I have a loop that loops through all records in all tables that have "TSE" as the first letters. In that loop, based upon conditions of the current record I have to add records to 1 of 5 different...
4
by: Bob | last post by:
Hi all, I'm trying to import data, modify the data then insert it into a new table. The code below works fine for it but it takes a really long time for 15,000 odd records. Is there a way I...
1
by: kccoolrocks1981 | last post by:
I need to create a temporary table in VBA Code but recordset.fields(i).Type gives me an integer value instead of the required field's Type. For an example Field_Name= "CriteriaName" and it's...
4
by: Pman12 | last post by:
Below is the vba code I am working with. When it gets to the insert part I get an "Enter parameter value" dialog box with the value of the variable "id" above the cursor. I have to type in that...
1
by: afromanam | last post by:
Hello, Good morning, I have a question, hope someone can help me. I have a table with say, 5 columns, each named A,B,C,D,E The table was imported from Excel, so picture please this:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...
0
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...

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.