473,387 Members | 1,391 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,387 software developers and data experts.

Access/SQL - Update records

I have an Access2003 database that we are converting the backend tables to SQL Server Express. Since this is one of my first times dealing with SQL Server Express, I am having a few issues with one of the programs. Basically it takes a temporary file created in the Access database and it needs to update two tables in the SQL database. I have part of the code below - the temporary file is tblRegister. If there is another way I need to do it, please let me know. Also if anyone has a code example of how I should open the tables and loop thru them - update and exit, that would be great. Thanks.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdPost_Click()
  2. Dim db, ldb As Database
  3. Dim rstR, rstC, rstT As Recordset
  4. Dim Msg, Style, Title, Help, Ctxt, Response, MyString
  5. Dim Lst As ListBox
  6. Dim strFill As String
  7. Set Lst = Me![lstMCNumbers]
  8. Style = vbYesNo ' Define buttons.
  9. Title = "Post registry"  ' Define title.
  10. Help = ""   ' Define Help file.
  11. Ctxt = 1000 ' Define topic
  12.         ' context.
  13.         ' Display message.
  14. Response = MsgBox("Post Registry into Customer list?", Style, Title)
  15. If Response = vbYes Then
  16. Set db = CurrentDb()
  17. 'Set db = OpenDatabase("n:\TestData\PascoData_041107.mdb")
  18. Set ldb = CurrentDb()
  19. Set rstR = ldb.OpenRecordset("tblRegister")
  20. 'Set rstC = db.OpenRecordset("tblCustomers", dbOpenSnapshot, dbSeeChanges)
  21. ''Set rstT = db.OpenRecordset("tblTransactions", dbOpenSnapshot, dbSeeChanges)
  22.  
  23. 'rstR.MoveFirst  'take out
  24. Do While Not rstR.EOF
  25.    rstC.FindFirst = "MCNumber=" & rstR.MCNumber '<if MCNumber is numeric
  26.  
  27.  ' rstC.Index = "MCNumber"  'take out
  28.  ' rstC.Seek "=", rstR.MCNumber 'take out
  29.   If rstR![PostIt] = True Then
  30.     If rstC.NoMatch Then
  31.       rstC.AddNew
  32.       rstC![MCNumber] = rstR![MCNumber]
  33.       rstC![DOTNumber] = rstR![MCNumber]  ''03/27/07 added by DRA for DOT#
May 29 '07 #1
1 1840
nico5038
3,080 Expert 2GB
Hmm, taking the hard way...

I would create unique indexes on the SQL Server tables and use an INSERT query in Access to add the not existing rows.
As the Unique index will prevent duplicates to be inserted, this is a safe (and fast) way to add new rows into a table.

Getting the idea ?

Nic;o)
Jun 2 '07 #2

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

Similar topics

29
by: Mark B | last post by:
We have an Access app (quite big) at www.orbisoft.com/download. We have had requests by potential users to have it converted to an SQL version for them since there corporate policy excludes them...
7
by: Doug Vogel | last post by:
Hi All - I have a client for whom I developed an Access 2000 database. The database is split into 2 files - front-end (forms, queries, reports), and back-end (tables). An .mde file has been...
0
by: htmlgeek | last post by:
I'm adding and updating records in an Access .mdb via WWW .asp page. Authored in Dreamweaver 2004 MX. Help is welcome on this one. I have a great set of pages that work fine, but it seems that...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
1
by: girlkordic | last post by:
I have a linked table from an Oracle database (that contains HR information for my company)in an Access database. The Oracle DB is updated on a daily basis. I would like one of my tables in...
7
by: mark | last post by:
Please excuse this blatant attempt at advertising. I hope you find this software both interesting and useful. http://www.caddproductivity.com/dataswap.htm Data Swap The Data Swap program...
0
by: | last post by:
I am updating MS access tables with data in an xml document. I create two dataset, one for existing data and one for new data. I fill the first dataset with the records from MS Access, the second...
9
by: thomasp | last post by:
First of all, thanks for the help on my previous VB.NET/MS Access questions. This time I need do the following 1. Connect to a table 2. step through each of its records 3. read the value of two...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
4
by: BFoxDDS | last post by:
i'm sure this is simple to do, but i can't find the answer in the search engines. i have an access db with 400,000 records. i produce queries of 5,000 records at a time exported into an excel...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...

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.