473,406 Members | 2,745 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.

Creating a data entry form from two tables with a many to many relationship

LeighW
73 64KB
Hi,

Another thing which I can't get my head around really.

Basically I'm trying to create a link so that when I create a new record within one of the tables I can select values from the other table which that record is related to within a form.

i.e.
I have two tables, tbl_Evidence and tbl_Reference linked by a junction table (tbl_EvidenceRef) which has enforced referential integrity. If I add a new record within tbl_Reference on the form how could I go about choosing the pieces of evidence from tbl_Evidence that relate to the new reference and vice-versa?

I want this to happen in a user-friendly way on a form

Leigh
Jun 1 '12 #1

✓ answered by NeoPa

LeighW:
Sorry for long winded answer. I hope what I say is doable. It seems like you can do everything in access in some way or another.
No need for apologies. You simply provided exactly what I requested you to. Also, you're right about Access. It pretty well can. Within reason of course. I've never seen a program make a cup of tea, but never say never right?

Mostly, getting Access to do what you want just takes a bit of thinking to determine exactly what it is you do want. You'd be surprised how much of the solution comes down to just that. There are other issues too, of course. Designing it once you have the blueprints, but that first step is the most important by far.

I've never used a many-to-many form setup before, but I would consider it sensible to have a linkage set up with referential integrity as a basic requirement. That would mean that the process of entering data would need to be done on a two-pass basis. Enter the underlying data first (Separate forms for each table) and, as a separate process, a linkage form that enables you to create records from two ComboBoxes linked to the PKs of each table.

If a more seamless approach is necessary, then the linkage form could have an option to link to a new record (Each ComboBox could provide that entry) and when either of those is selected the code could open the related data-entry form to allow the operator to enter a new record and then create a link to that new record in the linkage form.

Does that all make sense?

10 3166
Try DLookUp to pull what you want from the second Form
Jun 3 '12 #2
NeoPa
32,556 Expert Mod 16PB
How about a subform Leigh? That should give you everything you need.
Jun 3 '12 #3
LeighW
73 64KB
Thanks for the replies.

Paulo357:
How does DLookUp work? I've seen it used but wasn't sure where you actually insert the code (unless just using the lookup wizard is sufficient)?

On that note I tried creating a lookup data type using the wizard selecting source: 'Evidence' from the junction table, tbl_EvidenceRef as a new field (Lookup_Evidence) in tbl_IdRefs. When using this in the form as a list box it only shown one piece of evidence per reference rather than the multiple pieces of evidence it should have. Changing the list box to multiselect (extended) didn't let me choose the others either.

NeoPa:
Subforms I've tried to use but still not sure how to create a list/combo of the evidence I want to select from when creating a new record as it's a many to many relationship.

Also very tired at the moment after the long weekend so I'm sorry if these are stupid questions
Jun 6 '12 #4
NeoPa
32,556 Expert Mod 16PB
Maybe I'm misleading myself with the assumption that evidence will only ever pertain to one item (It's hard to know what a reference record might relate to so I can't conceive of what you're attempting to describe). Perhaps if you could describe how the items relate to each other I might find it easier to think about it.
Jun 7 '12 #5
There are many examples on MS Web site, that you can educate yourself from.. here is a starting point
Expand|Select|Wrap|Line Numbers
  1. =DLookUp("[LastName]", "Employees", _
  2.       "[EmployeeID] = Form![EmployeeID]")
  3.  
Generally you wont have much luck using the Wizard as it never compiles the code correctly or picks up the quotes when fields need it
Jun 7 '12 #6
LeighW
73 64KB
The evidence can have more than one reference though it is usually only one. I can't go into detail of any in the database unfortunately but say for example a river passes two sites and they each have a recording of around the same pollutants. Each site has a seperate reference but leads to the same evidence.

References however like a report from the Environmental Agency for example could relate to numerous pieces of evidence.

At present I have two forms and three tables as it's a many-to-many relationship. tbl_Evidence has all the "Evidence" in text form with related "PKEviNo" (Primary Key, Evidence Number as autonumber). tbl_IdRefEvidenceJoin is the junction table and is joined to tbl_Evidence via field "PK_EviNo" to "fldEviNo". tbl_IdRefEvidenceJoin also has the field "fldIdRefNo" which joins to tbl_IdRefs via "PK_IdRefNo". "PK_IdRefNo" is also an autonumber field which is linked to each Identified Reference "RefTitle" within tbl_IdRefs.

I've since populated the junction table with the "fldEviNo" that link to "fldIdRefNo". I am not sure whether I'm supposed to also enter the "Evidence" and "RefTitle" fields into the junction table.

The two forms, frm_Evidence and frm_IdRefs will be viewable to the masses. The only problem I'm having is when pressing add new record I want a list or combo box to become visible (which I believe is easy enough to do) perhaps in the form footer, which shows text fields "Evidence" or "RefTitle" in a bound multiselect box which you can click to choose which pieces of evidence relate to which reference and vice versa. I'd also like the join to then save so when you go to the new record it will still show the evidence/references it relates to.

Sorry for long winded answer. I hope what I say is doable. It seems like you can do everything in access in some way or another.
Jun 7 '12 #7
NeoPa
32,556 Expert Mod 16PB
LeighW:
Sorry for long winded answer. I hope what I say is doable. It seems like you can do everything in access in some way or another.
No need for apologies. You simply provided exactly what I requested you to. Also, you're right about Access. It pretty well can. Within reason of course. I've never seen a program make a cup of tea, but never say never right?

Mostly, getting Access to do what you want just takes a bit of thinking to determine exactly what it is you do want. You'd be surprised how much of the solution comes down to just that. There are other issues too, of course. Designing it once you have the blueprints, but that first step is the most important by far.

I've never used a many-to-many form setup before, but I would consider it sensible to have a linkage set up with referential integrity as a basic requirement. That would mean that the process of entering data would need to be done on a two-pass basis. Enter the underlying data first (Separate forms for each table) and, as a separate process, a linkage form that enables you to create records from two ComboBoxes linked to the PKs of each table.

If a more seamless approach is necessary, then the linkage form could have an option to link to a new record (Each ComboBox could provide that entry) and when either of those is selected the code could open the related data-entry form to allow the operator to enter a new record and then create a link to that new record in the linkage form.

Does that all make sense?
Jun 7 '12 #8
LeighW
73 64KB
That it does. I'm just in the process of redoing the junction table as I added too much unneccesary duplicate data. I'm hoping to get this right this time. Many-to-many relationships wreck the brain!

I'll report back with my progress shortly.
Jun 7 '12 #9
LeighW
73 64KB
I believe I've done it. Just got to design it into the form.

Thanks very much NeoPa. A serious weight off my mind. That's two ruddles now!

I found a detailed instruction on how to do it below if anyone is interested but never would of thought of looking there without the help!
** SNIP **
Jun 7 '12 #10
NeoPa
32,556 Expert Mod 16PB
Sorry Leigh. We don't allow links to competing forum sites :-( I've removed it for you. It looks like it was a good article though ;-)

Otherwise, I'm glad I was able to help, and I might just have to award myself those two pints of County from the fridge :-D
Jun 8 '12 #11

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

Similar topics

1
by: Artco News | last post by:
Hi, I was wondering if any of you experts has some example of MySQL data entry form either using PHP or any public domain software for my photo album. I'd like to enter some description with it. ...
2
by: Iain Miller | last post by:
Struggling a bit here & would be grateful for any help. I have a table which has a list of people in it. Each person has a unique ID automatically allocated by Access but also belongs to one of 5...
1
by: KC | last post by:
Hello, I am using Access 2002. WinXP, Template from MS called Orders Mgmt DB. I have tweaked this DB to work for our small co. It has worked pretty well up until I made the mistake of deleting...
4
by: Martin | last post by:
I want to build a data entry form for creating and updating info on something. When I'm first creating an item all the fields need to be editable. There after some fields become readonly. Most...
1
by: ajw | last post by:
I am a VB.NET newbie... I have a data entry form with text boxes bound to a dataset. The data source is an Access table with the primary key field being an autoincrement field. Everything works...
5
by: Aspnot | last post by:
Background: I have a data entry form that is bound to a DataSet. This DataSet contains 9 tables and the form displays data from each table in textboxes, not a DataGrid. One of the tables in the...
2
by: filbennett | last post by:
Hi Everyone, I'm generally unfamiliar with Access form design, but have programmed Cold Fusion applications for a couple of years. I'd like to build a data entry form in Access that allows the...
2
by: seltzer | last post by:
I am using Access 2000 but I also have the 2003 version. I am working on creating a data entry form in Access for a research study. Since there is a maximum of 255 fields per table in Access, I...
0
by: Tyler | last post by:
Made a data entry form which is a subform. I made a continuous form that displays everything entered through the data entry form. The data entry form displays all of the records. This doesn't...
0
by: Musky09 | last post by:
On a data entry form I am creating the answers to questions 2a1-6 are related to the answer to question 2a...If 2a is "N", questions 2a1-6 are "N/A"...If 2a is "Y", questions 2a1-6 can be "Y", "N",...
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?
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
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...

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.