473,396 Members | 1,836 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.

many to many relationship inserts

6
Hi all

I have a SQL Server 2000 database that I converted from an access database. The interface is still existing in Access...

Basically I have 2 tables in a many to many relationship - Member and Nominators of members. But because the same nominator can nominate many members and a member can be nominated by multiple nominators, i've added a linking table call MemberNomLink that has the MemberId and the NominatorId.

So in my access interface I have a parent form for the Member, and a subform of all the nominators for that member. When i enter, if the nominator is brand new (never nominated before) then I'd just do an insert - which would:

a) insert into the nominator form (giving a new IDENTITY Primary key - Nominator Id) and
b) would insert into the MemberNomLink table - the new NominatorId and the parent form's Member Id.

When I was running this in access, this worked fine by simply using a left join query on my subform between Nominators and MemberNomLink. When I inserted into this query, access seemed to automatically insert nominator, then create the MemberNomLink fine populating it with the new id.

When I'm attached to the SQL Server 2000 db though, it will insert into the nominator table, however it won't insert into the MemberNomLink.

I don't think this is an unusual circumstance but if anyone has done anything like this, I'd like to know if I'm doing something obviously wrong...

thanks in advance
scott
Nov 18 '07 #1
1 2685
Jim Doherty
897 Expert 512MB
Hi all

I have a SQL Server 2000 database that I converted from an access database. The interface is still existing in Access...

Basically I have 2 tables in a many to many relationship - Member and Nominators of members. But because the same nominator can nominate many members and a member can be nominated by multiple nominators, i've added a linking table call MemberNomLink that has the MemberId and the NominatorId.

So in my access interface I have a parent form for the Member, and a subform of all the nominators for that member. When i enter, if the nominator is brand new (never nominated before) then I'd just do an insert - which would:

a) insert into the nominator form (giving a new IDENTITY Primary key - Nominator Id) and
b) would insert into the MemberNomLink table - the new NominatorId and the parent form's Member Id.

When I was running this in access, this worked fine by simply using a left join query on my subform between Nominators and MemberNomLink. When I inserted into this query, access seemed to automatically insert nominator, then create the MemberNomLink fine populating it with the new id.

When I'm attached to the SQL Server 2000 db though, it will insert into the nominator table, however it won't insert into the MemberNomLink.

I don't think this is an unusual circumstance but if anyone has done anything like this, I'd like to know if I'm doing something obviously wrong...

thanks in advance
scott
You can achieve the same functionality using a 'trigger' in SQL although I have to say the after_update event of the appropriate NominatorID field in your interface could be used primarily to determine if apropriate values exists in the MemberNomLink table and if not to then insert them immediately following an insertion of a new nominator. You would then simply requery to refresh the interface.

What format frontend are you using MDB or ADP? Have a good look at the ADP format in Access if you are upsizing for the first time. You can choose either of these of course whichever you arecomfortable with, however the ADP format handily exposes views and stored procedures to you in the interface and connects directly to SQL server using UDL Universal data link ie it doesnt use ODBC connectivity. If you need to create tables locally on the client then stick with the MDB format (mdb is back in favour for Access 2007 too)

Have a go at the after update event based on my simple response here and if you get stuck then post your table structure ie 'exact' table and field names and I'll replicate the tables and necessary SQL on my server, create MDB and an ADP solutions to show you the relevant differences and then mail you the files which should work on your system provided the db name is the same too. Don't post your email address though. (if this progresses to that) you would have to PM me with it and I,ll mail you

Regards

Jim :)
Nov 19 '07 #2

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

Similar topics

3
by: kj | last post by:
When I run the attached query, I get duplicates when there is one to many relationship between tableA and tableB. The query, tested schema and the result is attached. Sorry for the long post. ...
2
by: Larry R Harrison Jr | last post by:
I have an Access 97 database with 2 tables that have a one-many relationship. I have a SQL statement in the "one" table which I want to execute and insert 7 records into the "many" table, and I...
2
by: Megan | last post by:
hello everybody, i know this is a very long post, but i wanted to provide as much detail as possible. quick overview- i want to create a couple of many to many relationships and am wondering...
1
by: Brian Maguire | last post by:
Can too many btree indexes cause page level locking? I read this... http://www.postgresql.org/docs/7.4/static/locking-indexes.html
13
by: the other john | last post by:
The trouble currently with 3 tables. I'm excluding non-relevant fields... tbl_users PK_user_ID tbl_developers PK_developer_ID FK_developer_user_ID FK_developer_project_ID
4
bugboy
by: bugboy | last post by:
I'm inserting a new word into table 'w' and a definition into table 'c' which are linked in table 's' which is the relation table for the many to many relationship between 'w' and 'c'. I've been...
5
by: smook | last post by:
Hi all I have a SQL Server 2000 database that I converted from an access database. The interface is still existing in Access... Basically I have 2 tables in a many to many relationship -...
2
by: paulcjcross | last post by:
How to set up a many to many relationship. I know you need a third table to join the other two. I need one table (table1) with stock_numbers(unique), one table (table2) with job-numbers(unique) and...
6
by: NicoleCartrette | last post by:
Going back to school is easier said than done.. This was posted to an older thread earlier but I don't think it got any attention. Your help is appreciated Professor requires we create a...
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: 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:
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
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...
0
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 project—planning, coding, testing,...

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.