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

Using SQL Triggers and Access Subforms

Hello,

I wonder if anyone can shed light on this problem for me. I have an
Access 97 front end with an SQL 2000 database. There is a Business main
form with an Owner subform and corresponding tables of the same names.
A third table BusinessRel records the BusinessID (linked to Business
table) and OwnerID (linked to Owner table).

This is what happens when the Business main form is loaded. I enter the
BusinessID and other stuff, then as soon as I click on the Owner
subform the BusinessID is hightlighted in a BusinessID field on the
subform. In the background I have a trigger on the Business table to
create the Owner record and a trigger on the Owner table to create the
BusinessRel record. (These all get created perfectly becuase if I close
down the main form and load it up I can edit the Owner subform fields.
However, if I click on the Owner fields to enter more details an error
comes up basically stating that there is no such Owner record. Although
there is, because the triggers work.

I have a feeling that this is only [Bad] news to me. And is due to the
main form and subform and SQL trigger timing.

I would appreciate any advice or help you can give to resolving this.

Kind regards

Terry

Nov 13 '05 #1
2 3087
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It seems you're doing more work than is necessary.

Why do you have a "joining table" BusinessRel? That is usually a
solution to a Many-to-Many relationship problem. I.e., many business
have many owners and many owners have many business. Is that your
situation? If it isn't remove the table BusinessRel and the trigger on
the Owners table.

Usually, when I have a many-to-many suitation I have a main form that
represents the "left" side of the relationship and a subform that
represents the "right" side of the relationship. The subform feeds the
joining table. The Link Child Field holds the right side's ID and the
Link Master Field holds the left side's ID. I put a ComboBox on the
subform that selects the "right" side ID.

In your case the main form would be the Business side (the left side)
and the subform would be the Owners (the right side). Every time you
select an Owner from the subform's ComboBox both IDs would be saved to
the joining table.

You have to create the entities before linking them in the joining
table. IOW, there would be an Owners form w/ a Business subform and a
Business form w/ an Owners subform. Before adding an owner to the
Business-Owners join there has to be both a Business entity & and Owner
entity. Ditto for adding a business to an owner.

You can set up the subforms to allow the user to enter a new entity if
they find it isn't one of the entities on the ComboBox's selection list.
I usually use a button labeled "Add <entity type>." E.g.: "Add
Owner." The button click would bring up the data entry form for the new
entity.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQmhb94echKqOuFEgEQIWpwCeOaxSitQiLQdty77SgZ7TGs qFpWYAn2lK
8tIPsazqTqzUrwNtx6uEgJgI
=yuPi
-----END PGP SIGNATURE-----

Terry wrote:
Hello,

I wonder if anyone can shed light on this problem for me. I have an
Access 97 front end with an SQL 2000 database. There is a Business main
form with an Owner subform and corresponding tables of the same names.
A third table BusinessRel records the BusinessID (linked to Business
table) and OwnerID (linked to Owner table).

This is what happens when the Business main form is loaded. I enter the
BusinessID and other stuff, then as soon as I click on the Owner
subform the BusinessID is hightlighted in a BusinessID field on the
subform. In the background I have a trigger on the Business table to
create the Owner record and a trigger on the Owner table to create the
BusinessRel record. (These all get created perfectly becuase if I close
down the main form and load it up I can edit the Owner subform fields.
However, if I click on the Owner fields to enter more details an error
comes up basically stating that there is no such Owner record. Although
there is, because the triggers work.

I have a feeling that this is only [Bad] news to me. And is due to the
main form and subform and SQL trigger timing.

I would appreciate any advice or help you can give to resolving this.

Kind regards

Terry

Nov 13 '05 #2
MGFoster wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It seems you're doing more work than is necessary.

Why do you have a "joining table" BusinessRel? That is usually a
solution to a Many-to-Many relationship problem. I.e., many business
have many owners and many owners have many business. Is that your
situation? If it isn't remove the table BusinessRel and the trigger on
the Owners table.

Usually, when I have a many-to-many suitation I have a main form that
represents the "left" side of the relationship and a subform that
represents the "right" side of the relationship. The subform feeds the
joining table. The Link Child Field holds the right side's ID and the
Link Master Field holds the left side's ID. I put a ComboBox on the
subform that selects the "right" side ID.

In your case the main form would be the Business side (the left side)
and the subform would be the Owners (the right side). Every time you
select an Owner from the subform's ComboBox both IDs would be saved to
the joining table.

You have to create the entities before linking them in the joining
table. IOW, there would be an Owners form w/ a Business subform and a
Business form w/ an Owners subform. Before adding an owner to the
Business-Owners join there has to be both a Business entity & and Owner
entity. Ditto for adding a business to an owner.

You can set up the subforms to allow the user to enter a new entity if
they find it isn't one of the entities on the ComboBox's selection list.
I usually use a button labeled "Add <entity type>." E.g.: "Add
Owner." The button click would bring up the data entry form for the new
entity.

I've also had problems using triggers with Access (when the trigger
updated other records than the current one) I solved it by creating an
independent control, and using the _afterupdate-event to update the
table (Docmd.Runsql)
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: B Moor | last post by:
SQL Server 2000 sp3; single instance; used as backend to Access 2002: I have 20 tables used as a temporary store, each one receiving data from VB based remote applications that insert new data on...
1
by: John Mudd | last post by:
I come from the Access environment where all the windows form handles were hidden so pardon my question. In Access I could make "continuous" subforms and there was a subform "container" object I...
1
by: E. Zorn | last post by:
Hi, i use Access as a frontend via ODBC to an Linux-based postgresql. I have a problem in a form where I use a lot of subforms. In some cases ( i couldn't detect when - but I really try to) the...
7
by: Julia Baresch | last post by:
Hi everyone, My company recently upgraded from Office 97 to Office XP. As those who've read my other posts know I have a database with 3 nested subforms Main form-->First Subform-->Second...
0
by: CSDunn | last post by:
Hello, In Access ADP's that connect to SQL Server databases, any time I have a situation where I have a combo box in a main form that looks up a record in a subform, the subform record source has...
3
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality...
1
by: ashkash | last post by:
I have an access database which takes information from a user and then uses the mail merge functionality to merge the data into a word document. I have a lot of subforms in the access database which...
6
by: JonC | last post by:
I am developing an Access database and need to be able to print a form with various selections made as it appears on screen. The standard way of doing this would be to create a report based on the...
2
by: David Haskins | last post by:
I have a fairly complex interface screen (form) that is comprised of several subforms that perform different, but related activities. I am designing a search/filter form that should be able to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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.