473,396 Members | 2,017 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,396 software developers and data experts.

How to connect to access database with multiple tables and add/update the records?

I have four tables in access 2003: T1 (8 fields), t2 (5 fields), t3 (7 fields), t4 (3 fields) all connected to each other with t1.a = t2.a, t1.a=t3.a, t1.a=t4.a (T2, T3 and T4 contains the FK for T1.
My program has a listbox with t1.a populated on it. When the user clicks on an "a value," it would search the database and populate the textboxes which are supposedly connected to the fields (distributed to the 4 tables).
My concern is: is it possible to connect to all of these tables and populate my vb6 text boxes from them for viewing of records? I also need to be able to update the records.
Would this query work?
Expand|Select|Wrap|Line Numbers
  1. strSearch=lstNames.list(lstNames.listindex)
  2. SELECT * FROM t1, t2, t3, t4 WHERE t1.a >= " & strSearch
Feb 6 '11 #1
1 4236
Stewart Ross
2,545 Expert Mod 2GB
Not as you show it, as there are no joins between the tables - you would have the Cartesian product of the four tables instead.

You'll need to use appropriate inner joins between the four tables, like this:

Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM ((t1 INNER JOIN t2 ON t1.a = t2.a) 
  3.           INNER JOIN t3 ON t2.a = t3.a) 
  4.           INNER JOIN t4 ON t3.a = t4.a;
You should really select the actual fields you need and apply appropriate aliases to guarantee uniqueness, however, as including them all will result in a number of name clashes that can only be resolved by qualifying the field names with the table name concerned.

you will also have to ensure if you want to do updates that you maintain the correct primary key/foreign key relationship throughout - no accidental changing of foreign keys that could leave records dangling without matching primary keys, for instance.

-Stewart
Feb 6 '11 #2

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

Similar topics

3
by: Thomas Tsang | last post by:
I am using ASP + IIS + MS access, when running the following codes: set Conn=Server.CREATEOBJECT("ADODB.CONNECTION") conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; " &...
7
by: vigneshwaran G via DotNetMonster.com | last post by:
Hi , I am trying ot connect a VB application to Access database. iam using the following connection string : con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;data source=c:\...
2
by: George | last post by:
Hi all, I am trying to convert to vb.net from VB6 and I am haveing a major problem with connecting to an Access database and adding, updating, deleting data. This is what I usually use in vb6:...
1
by: rajusonavane | last post by:
hi i m helpless on connect oracle or access database with xml programm plz give me sample code of program how to connect thanking you raju
1
by: Magnus | last post by:
I'm testing walkthrough saving data to a Database (Multiple Tables). http://msdn2.microsoft.com/en-us/library/4esb49b4(VS.80).aspx In the famous Customer/Order example, I'm getting referential...
0
by: asad56 | last post by:
I am workin with a superstore managment project. I connect Access database with main form . Then it work properly. But now I connect same database with another table or field in another form which is...
2
9815402440
by: 9815402440 | last post by:
hi i want to connect access database which is on remote server (web server). can anybody please tell how to do this? thanx in advance. manpreet singh dhillon hoshiarpur
7
by: emajka21 | last post by:
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...
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:
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.