473,782 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access 2003-How to update records in 2 separate Access databases

38 New Member
I have been working on creating a HR database. Everything is working fine there but now they want a training database. I basically need a few fields from the employee table and I need the full department table. I also need the position titles table along with 1 additional field. I was able to export everything fine to the new database.

Is there a way to update the training database when data is updated in the HR database. I figured out how to do an append when a new employee is added but I'm not sure how to delete and update records between multiple databases. The name of the other database is DRR.MDB.

I have found how to link tables between databases but I don't want to give the DRR database the entire employee record, only part of it. I could break the table apart but then I would have to do ALOT of reprogramming of forms and reports and I will only do that as a last resort.

Is there a way to open the DRR database through code from the HR database and run a SQL update/delete query to update records in the DRR?

Thanks for any insight to this problem you might have!
Oct 17 '08 #1
7 2889
missinglinq
3,532 Recognized Expert Specialist
I expect someone will be along that can guide you in this, but in every organization I've worked in that used a database for this kind of thing, the training data was part and parcel with the HR database. In the health care field, HR has to know who's been trained in what procedures and when they come up for renewal of certifications. If persons outside of the HR department need access to enter data, you just give them limited access. Much easier than trying to maintain two almost identical databases.

Linq ;0)>
Oct 18 '08 #2
ADezii
8,834 Recognized Expert Expert
Is there a way to open the DRR database through code from the HR database and run a SQL update/delete query to update records in the DRR?
Here is one approach that you can look at.

Here is some code that I put together for you that will Update 3 Fields ([Address], [City], and [PostalCode]) in an Employees Table in an External Training Database named Training.mdb (C:\Test\Traini ng.mdb). This process is done completely from within the context of the Current Database, and maintains no Linkage or Connectivity whatsoever with the Training Database. The code does, however, assumed that the 2 Employees Table have identical Field Names and Data Types. If they were not the same, it would not pose a problem, I did it this way simply for demo purposes. I'll stop rambling and simply post the code, any questions, please feel free to ask:
Expand|Select|Wrap|Line Numbers
  1. Dim wrkJet As Workspace
  2. Dim dbsTraining As DAO.Database
  3. Dim dbsCurrent As DAO.Database
  4. Dim rstTraining As DAO.Recordset
  5. Dim rstCurrent As DAO.Recordset
  6. Dim strPathToTrngDB As String
  7.  
  8. strPathToTrngDB = "C:\Test\Training.mdb"
  9.  
  10. 'Create Microsoft Jet Workspace object.
  11. Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
  12.  
  13. 'Open Training Database exclusively
  14. Set dbsTraining = wrkJet.OpenDatabase(strPathToTrngDB, True)
  15.  
  16. Set dbsCurrent = CurrentDb()    'Current Database
  17.  
  18. 'Open Recordset based on the Employees Table of the Training Database
  19. Set rstTraining = dbsTraining.OpenRecordset("Employees", dbOpenDynaset)
  20.  
  21. 'Open Recordset based on the Employees Table of the Current Database
  22. Set rstCurrent = dbsCurrent.OpenRecordset("Employees", dbOpenSnapshot)
  23.  
  24. Do While Not rstTraining.EOF
  25.   Do While Not rstCurrent.EOF
  26.     'Match specific Employee in Training to Current DBs
  27.     If rstTraining![EmployeeID] = rstCurrent![EmployeeID] Then
  28.       rstTraining.Edit
  29.         rstTraining![Address] = rstCurrent![Address]
  30.         rstTraining![City] = rstCurrent![City]
  31.         rstTraining![PostalCode] = rstCurrent![PostalCode]
  32.       rstTraining.Update
  33.     End If
  34.     rstCurrent.MoveNext         'Next Employee/Current DB
  35.   Loop
  36.   rstCurrent.MoveFirst          '1st Employee/Current DB
  37.   rstTraining.MoveNext          'Next Employee/Training DB
  38. Loop
  39.  
  40. rstTraining.Close
  41. rstCurrent.Close
  42. Set rstTraining = Nothing
  43. Set rstCurrent = Nothing
P.S. - Linq makes some excellent points about you logic.
Oct 18 '08 #3
DonRayner
489 Recognized Expert Contributor
Break your table apart and rename each part something else like "Mytable1", "Mytable2"..... Then create a query to gather everything back togeather and give it the name of the origional table "Mytable", your forms and reports will treat the query just like it was the origional unsplit table. You can then keep all of the records in the HR db, create your Training DB as a frontend application only and link the required tables into it.

You might run into a few problems if you are running SQL or recordsets in your VBA code but it should be quick and easy to fix up.
Oct 18 '08 #4
emajka21
38 New Member
First, thank you all for responding to me.

Linq,
1. We're not the normal organization (or else things might be easier! :)
2. The HR database is located in the HR network drive. There are only about 3-4 people who have access to any portion of this drive and they are not willing to give it to this other person. (Heck they truthfully don't want me to look at the info.) Management is highly paranoid.
3. This DRR database is also "hopefully" going to be temporary.
4. DRR's are only a tiny portion of the training that goes on here and they are also currently looking at redoing how they handle training (they are looking for a full blown training system for next year.) Another reason this database is probably only temporary.
5. DRR's stand for Document Review Request. Bascially employees need to look at a list of documents once as year as part of their training. They also need to be notified when a document changes. We are currently inplementing a new Document Management system in which we are hoping to configure the system to send out these review notifications but it will take several months for all the kinks to be worked out. Which is again, another reason this database is hopefully temporary. HR does not handle these requests, the document management coordinator does.


I could keep going on with the list of reasons but I won't. I was hoping this was just going to be an easy thing, but of course, nothing in life is easy. :) I was just trying to make life a little easier for the person until all of the other things were finished because now all of this info is kept on paper and several spreadsheets. VERY INEFFICIENT!


ADezii,
Looking at the code it looks like this will compare all the records in both tables. Is there are way to make it update the 1 record only at the time of the change (through a form)? For example, if a person moves departments and HR updates their database, can it then at that point (maybe at an onchange event) update the DRR database? The key in both databases is their EmployeeID. Also how would a delete work? Currently I have the HR system move the employees record to a terminated table if the employee's record gets marked for termination. I would like add another procedure during this that would delete it from the DRR table.


DonRayner,
This would probably be the easiest thing to do but it would also give the other person access to the raw data and splitting it apart is still a pain in the butt. But at the same time it makes alot of sense, especially if the DRR database is only going to be temporary...

I will consider this further before I make any drastic changes. But for curiousity's sake I would still like to know how to update/delete the way ADezii is describing. :) Having choices is good. :)

Thanks again!
Oct 20 '08 #5
ADezii
8,834 Recognized Expert Expert
First, thank you all for responding to me.

Linq,
1. We're not the normal organization (or else things might be easier! :)
2. The HR database is located in the HR network drive. There are only about 3-4 people who have access to any portion of this drive and they are not willing to give it to this other person. (Heck they truthfully don't want me to look at the info.) Management is highly paranoid.
3. This DRR database is also "hopefully" going to be temporary.
4. DRR's are only a tiny portion of the training that goes on here and they are also currently looking at redoing how they handle training (they are looking for a full blown training system for next year.) Another reason this database is probably only temporary.
5. DRR's stand for Document Review Request. Bascially employees need to look at a list of documents once as year as part of their training. They also need to be notified when a document changes. We are currently inplementing a new Document Management system in which we are hoping to configure the system to send out these review notifications but it will take several months for all the kinks to be worked out. Which is again, another reason this database is hopefully temporary. HR does not handle these requests, the document management coordinator does.


I could keep going on with the list of reasons but I won't. I was hoping this was just going to be an easy thing, but of course, nothing in life is easy. :) I was just trying to make life a little easier for the person until all of the other things were finished because now all of this info is kept on paper and several spreadsheets. VERY INEFFICIENT!


ADezii,
Looking at the code it looks like this will compare all the records in both tables. Is there are way to make it update the 1 record only at the time of the change (through a form)? For example, if a person moves departments and HR updates their database, can it then at that point (maybe at an onchange event) update the DRR database? The key in both databases is their EmployeeID. Also how would a delete work? Currently I have the HR system move the employees record to a terminated table if the employee's record gets marked for termination. I would like add another procedure during this that would delete it from the DRR table.


DonRayner,
This would probably be the easiest thing to do but it would also give the other person access to the raw data and splitting it apart is still a pain in the butt. But at the same time it makes alot of sense, especially if the DRR database is only going to be temporary...

I will consider this further before I make any drastic changes. But for curiousity's sake I would still like to know how to update/delete the way ADezii is describing. :) Having choices is good. :)

Thanks again!
Looking at the code it looks like this will compare all the records in both tables.
One Table is actually a Lookup Table that enables you to retrieve the Start and Stop Ranges for a given State.
Is there are way to make it update the 1 record only at the time of the change (through a form)?
That's exactly what the demo does, or parallels.
Oct 20 '08 #6
emajka21
38 New Member
Ok I got it to work. I modified it some:
-----------------------------------------------------------------------
Private Sub cboPositionTitl e_Change()
Dim wrkJet As Workspace
Dim dbsTraining As DAO.Database
Dim rstTraining As DAO.Recordset
Dim strPathToTrngDB As String

Dim test As Integer

strPathToTrngDB = "h:\DRR.mdb "

'Create Microsoft Jet Workspace object.
Set wrkJet = CreateWorkspace ("", "admin", "", dbUseJet)

'Open Training Database exclusively
Set dbsTraining = wrkJet.OpenData base(strPathToT rngDB, True)

'Open Recordset based on the Employees Table of the Training Database
Set rstTraining = dbsTraining.Ope nRecordset("Emp loyee", dbOpenDynaset)

test = 0

Do While test = 0 And Not rstTraining.EOF 'Ends once there is a match or Training EOF is reached
'Match specific Employee in Training to Current DBs
If rstTraining![EmployeeID] = Me.EmployeeID Then
rstTraining.Edi t
rstTraining![PositionTitleID] = Me.PositionTitl eID
rstTraining.Upd ate
test = 1
End If

rstTraining.Mov eNext 'Next Employee/Training DB
Loop

If test = 0 Then
MsgBox "Employee was not found in DRR database. Please notify Doc Coordinator of change."
End If
rstTraining.Clo se

Set rstTraining = Nothing

End Sub
------------------------------------------------------------


I will add this to all the fields that are needed in the DRR database.

Thanks for your help!
Oct 20 '08 #7
ADezii
8,834 Recognized Expert Expert
Ok I got it to work. I modified it some:
-----------------------------------------------------------------------
Private Sub cboPositionTitl e_Change()
Dim wrkJet As Workspace
Dim dbsTraining As DAO.Database
Dim rstTraining As DAO.Recordset
Dim strPathToTrngDB As String

Dim test As Integer

strPathToTrngDB = "h:\DRR.mdb "

'Create Microsoft Jet Workspace object.
Set wrkJet = CreateWorkspace ("", "admin", "", dbUseJet)

'Open Training Database exclusively
Set dbsTraining = wrkJet.OpenData base(strPathToT rngDB, True)

'Open Recordset based on the Employees Table of the Training Database
Set rstTraining = dbsTraining.Ope nRecordset("Emp loyee", dbOpenDynaset)

test = 0

Do While test = 0 And Not rstTraining.EOF 'Ends once there is a match or Training EOF is reached
'Match specific Employee in Training to Current DBs
If rstTraining![EmployeeID] = Me.EmployeeID Then
rstTraining.Edi t
rstTraining![PositionTitleID] = Me.PositionTitl eID
rstTraining.Upd ate
test = 1
End If

rstTraining.Mov eNext 'Next Employee/Training DB
Loop

If test = 0 Then
MsgBox "Employee was not found in DRR database. Please notify Doc Coordinator of change."
End If
rstTraining.Clo se

Set rstTraining = Nothing

End Sub
------------------------------------------------------------


I will add this to all the fields that are needed in the DRR database.

Thanks for your help!
You are quite welcome
Oct 20 '08 #8

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

Similar topics

0
1612
by: Gerald Bauer | last post by:
Hello, I invite you to cast your vote in the Year 2003 awards sponsered by the Java Republic, the Saturn Times and the Richmond Post news blogs. Here's the line-up: * What is Your Scripting Language for Java of the Year 2003? online @ http://viva.sourceforge.net/republic/2003/12/poll_what_is_your_scripting_language_for_java_of_the_year_2003.html
8
3458
by: Brad Tilley | last post by:
Does Python run on Windows Server 2003? http://www.python.org/download/download_windows.html only lists the following: Python for Windows 95, 98, NT, 2000, ME, XP
1
1955
by: chris mancini | last post by:
I have recently installed Visual Studio .Net 2003 and have noticed that there are problems with formatting in the HTML code page. If I format the HTML the way I want and navigate back to design view then the changes in the code page are lost. I searched around and found that there was a patch for Visual Studio .Net 2002 referenced by Microsoft Knowledge Base Article - 324199. I tried to load this patch but of course it won't patch 2003....
0
1889
by: MarionEll | last post by:
XML 2003 to Highlight Key Publishing Trend: XSL-FO Tools XSL-FO “Chef’s Tools Exhibition” Slated for 7 p.m. Dec. 10; Premier XML Industry Event Runs Dec. 7-12 in Philadelphia Alexandria, Va. October 7, 2003 - IDEAlliance, a leading trade association dedicated to fostering XML and other information technology standards, today announced that XML Conference and Exposition 2003 will feature an XSL-FO “Chef’s Tools Exhibition”...
0
1535
by: MarionEll | last post by:
XML 2003 Interoperability Demonstrations to Showcase Industry Standards, Integrated Vendor Solutions Alexandria, VA – Nov. 19, 2003 – IDEAlliance, a leading trade association dedicated to fostering information technology standards, today announced that XML Conference and Exposition 2003 will feature several “interoperability demonstrations” organized by OASIS, W3C, and WS-I. The demonstrations will showcase numerous...
0
6139
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug file as folows. I need help to resolve them ASAP: cl /c /nologo /MDd /W3 /Od /GR /GM /Zi /GX /D "_DEBUG" /D " WIN32" /D "_W INDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /
3
2734
by: Lee Gillie | last post by:
I have a VS6 project which I brought into VS .NET, and all has been building fine. Then I upgraded to VS 2003 and I have one source which will no longer compile. Any clues? Compiling... DotNetManagedExport.cpp C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcom.h(5529) : error C2872: 'CONNECTDATA' : ambiguous symbol could be 'C:\Program Files\Microsoft Visual Studio .NET
2
1454
by: noleander | last post by:
I'm trying to get Vis C++ std to compile using /O2 optimizing flag. Many people have suggested downloading the MS C++ 2003 Toolkit ... it supposedly has C++ compiler bins that one could use. I downloaded the 2003 Toolkit ... but the bin files are identical (size, date, contents) as my existing Vis C++ compiler. I have listed the file sizes below. Can someone who has downloaded the 2003 Toolkit see what file sizes and fiel dates ...
9
2309
by: Marc Miller | last post by:
Hi all, I have 2 dev. machines, the 1st is Win 2000 with .NET 7.0 and the 2nd is XP Pro with .NET 2003. My Web Server is Win 2000 Server with IIS 5.0. I can create a new project on my test server from the 1st machine, but I receive an 'HTTP/1.1 500 Internal Server error" from my Web Server. My userid/password are the same on all 3 machines.
5
1429
by: Randall Parker | last post by:
Running XP Home which does not come with IIS. In response to advice received on this forum I installed the Cassini web server to serve in place of IIS. See here for Cassini: http://www.asp.net/Projects/Cassini/Download/Default.aspx?tabindex=0&tabid=1 Trying to create an asp.net project in VS 2003. When I try to create the problem I get this error: "The default Web access mode for this project is set to file share, but the project...
0
9643
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9480
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10081
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5378
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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
2
3643
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.