Create an access dropdown based on a many to many relationship - ms-access

I have a database which holds data about audio files.
The main three tables are Volume, Author, and VolumeWithAuthor. A volume can have multiple authors, and an author multiple volumes, so they each have a many to one relationship with the VolumeWithAuthor table.
They look like this:
Volume:
ID- set to autonumber
Volume- the name of each file
Author:
AuthID- autonumber
AuthName- a string with the author name
AuthTitle- Dr., Mr. or Mrs., etc.
They are joined on the VolumeWithAuthor:
ID- autonumber
Volume- linked to Volume.Volume
AuthID - linked to Author.AuthID
I have a form linked to the Volume table. Users need to be able to input authors on that form. So the dropdown has to display the entries from Author.AuthName, and then create a new entry in VolumeWithAuthor.
I created a subform that displays all of the authors for each recording, but I can't work out how to add a dropdown.
I think this is something that is probably fairly basic, but I didn't see any similar questions that had answers that worked for me.
Thanks

Perhaps just a typo in your narrative, but need to select authors to VolumeWithAuthor, not Volume.
Options for data entry:
main form bound to Volume and subform bound to VolumeWithAuthor with a combobox to select author
main form bound to Author and subform bound to VolumeWithAuthor with a combobox to select volume
one form bound to VolumnWithAuthor with comboboxes to select volume and author
Use combobox Not in List event to add new author or volume to those tables on-the-fly during data entry.

Related

Saving a separate record when saving the current record

In my MS Access application the user opens the database to enter research notes (RNs). Each RN record needs to be attached to a project. All research notes entered during the current session relate to a specific project, which the user nominates on the first form. However, the RN - Project relationship is many-to-many. Although a single Project is attached when the RN record is created, other projects can be related later.
So... when I create and save a new RN record, I want to create a join table record with the new RN ID and the ID of the selected Project. I cannot find a way of creating this second record when creating the RN record. Does anyone have a way? Thanks
As June7th implied, It doesn't sound like you have ruled out the normal access forms/subforms approach. create a new database then insert the tables behind your many to many relationship. Then go to the database tools tab and tell access about the many to many relationship. For instance:
next select either of your main forms and then on the create tab select form and access will use the information about the relationships to auto-generate a rather ugly but working form and subform:
Form Prettification is Recommended before giving to actual users. Play around with the circled record selectors and try entering some data. Then check the tables and you will see that they have been properly updated. This approach may not work for your particular case, but try it because it is the easiest and fastest approach. Next approach is to add a button which associates a note and a project then runs some vba to add them to the junction table between notes and projects.

Autogenerate new reservation number for existing clients MS Access

I need help. I am designing a library DB in Access and I am having some trouble with the book reservation and loan forms.
I have the following tables:
librarymember (LibraryMemberNumber is auto generate number PK)
BookReservation (ReservationNumber is autogenerate, datetime stamp and librarymember as FK to librarymember PK)
BookReservationDetail (ReservationNumber, ISBN, NOtified, cancelled and completed check box fields)
Books (ISBN as PK, Title etc)
My query is as per image below:
main query image
I can generate new records in the table but I want to generate new records in the form. I have set the data entry property to yes but when I select the field box and try to enter in a library member ID it throws an error letting me know that it cannot be edited as it is bound to the expression librarymembernumber. I just want the form to show only a new record, type the library number in, and the form to generate the next reservation number. Is this possible?
Here you have 3 entities, all one-to-many: Library Member, Book Reservation Header and Book Reservation Details. You are trying to create two entities at the same time in the same line of form, it's impossible for one-to-many relations.
You have at least two ways for resolution:
Keep existing Book Reservation form, remove Library Member from base query, Library Member FK convert to combobox and select Member using this combobox. For creating/editing of Library Members create a separate form
Create editing form for Library Member, as subform use form for editing Book Reservation, which has Reservation Details as a subform, so, you will have 3 tier form.
I would use variant #1, it's easier to implement and use. For Members editing add a command button.

ms-access: autonumber format lost in query

I have to develop this database for my work and one part of it is that I have 4 different types of members that need to available to the system: Students, Parents, Mentors, and Coaches. Each have different information associated, so they all have their own table. Another table is a "notes" table that I want to be able to attach and unlimited number of notes to each member.
So for each table, there is a formatted autonumber. For students this number should be S#### in an incremental order. It doesn't matter the number and there will be far fewer than 9,999 students so I'm confident that's all I'll need. Then there's also P#### for parents, and so on.
It needs to be this way because the database also houses survey questions and responses. My notion is that survey responses can be uniquely identified by the member_ID, year, and term taken (since they're only open certain times). The problem is that without the formatted autonumber being found in the query, then ID's will be repeated and non-unique.
So my question is, does format autonumber not work? Am I going to have to use some VBA to build my own autonumbered string that will carry over through queries and other table lookups?
EDIT: So HansUp (below) suggested using a master list that the member tables feed off of. I've set this up since I haven't thought of an alternative. Basically, the flow is this:
Database user clicks "New Student"
"new student" form opens, along with "new member".
"new member" form creates a new ID # and assigns S group, sets viability off
Concatenated ID is then passed to "New student" form
If OK, then all changes are comitted
If cancel, then DoCMD.Undo for both new student and new member.
Would this do it? I'm not exactly sure how to pass that undo statement to the "New member" form though...
Leave the auto-number field as it is. it won't help you even if it does to your current business requirement it will create problem once your application grows further.
Use GUID/UUID to overcome database-level (or even global level) unique ID issues. This way you will maintain an unique ID throughout your database which will help in your case to have only one "notes" table for all of your entities.
in short:
Add a GUID field in your tables
Use triggers or public function/macro to generate the GUID
try to merge students, parents, mentor & coach into one table by separating them by "Type"
Remember an auto-number field is not continuous (in case if some records get deleted the gab will be there)
you can always perform string concatenation/format to produce S12355 number in your query to present it to your end-users.
I guess your main goal is to use only one note table for all of your users. GUID would be the way to go.
here some starting point: How can I generate GUIDs in Excel?

Access Form Wizard for Two Simple Subforms

In Access 2013, I can't use the Form Wizard to add two subforms. Well, the wizard, to be exact, skips the 'choose the main form' step, and upon completion fails to display the main form, only the header. I've replicated this on another computer.
For example, see 3 tables...
First called 'Users' with an ID (PK) and a 'Full name' field.
Second called 'Music' with an ID(PK), a UserID(Number) and 'Song' field.
Third called 'Movies' with an ID(PK), a UserID(Number) and a 'Movie' field.
The relationships are linking the ID of the Users table to UserID of the Music and Movies tables. All very simple. Distilled to its most simple form.
I use the Form Wizard to add 2 fields to show the 'Full Name' of the Users table and the 'Song' field of the Music table, then all is well, and the wizard produces a workable, if unsightly, Form.
Adding the 'Movie' field on top of the 'Song' field (accessing two other linked tables instead of one) means that the next step, choosing the main form, is skipped and the resulting form is empty is User mode but shows fields (no subforms) in Design mode.
Is this a bug in Access or I'm doing it wrong?
Thank you for you time.
Here's a link to some screenshots and database I made for you (It's a OneDrive shared folder). http://1drv.ms/1yrZyvt
Your problem is exclusively by relation between tables.
You connect USERS to MUSIC and MOVIES for 1 to 1, in this case you need almost one register to see information... and can't add any new in one of other tables.
If you modify the relation and main select of the form, the you can run normally.
Put this on the form and you can see that run perfect:
SELECT Users.FullName, Music.Song, Movies.Movie
FROM (Users LEFT JOIN Music ON Users.[ID] = Music.[UserID]) LEFT JOIN Movies ON Users.[ID] = Movies.[UserID];
Some help for this configuration:
Do relationship on tool.. not on every form. It's more easy to maintain
Do always relations based on main registry (normally 1 to many)
When insert any form into another, you can decide how to see and which field maintain the relation between.
Good luck

Using ActiveRecord to achieve complex relations in Rails

From another question of mine:
What I need to achieve is this: Create multiple categories with their
own designated information fields (ie. Cars have different fields from
Pets) and once such a category is created, the commands I need will be
invoked and a new table for each category will be made. I know I could
store all fields as some sort of string and then process it to display
it properly, but I need a advanced search function for my web app and
creating separate tables for each category seems the best way to
achieve it. I would really like to hear alternatives for this
So I have this situation where I need categories to hold all input fields needed for that certain category. So in administration I'd have this form where I'd be able to add the category name, some other relevant information to the category itself, and then these fields that would collect information on what HTML fields to present to the user when making an entry to this certain category.
For example this would be a Dog category:
Category name: Dog
Category enabled: 1
Category parent: Pets
Fields:
Title - text field (will be auto added to each category)
Breed - select field
Age - number field
Color - text field
Price - number field (will be auto added to each category)
Description - text area field (will be auto added to each category)
So now at this stage when the user created all these certain fields for the Dog category, Im having trouble figuring what would happen when the user hits the submit button to save this category. I thought of these two solutions:
Create a new model/table for each new category (Read linked question above) with all the HTML fields as columns and also store a row on the categories table with some basic info about this category
Store everything in the categories table and have a fields_json column which will store all HTML field information (I wont be actually storing HTML, but basic info what the fields are about then create the HTML form fields dynamically in a controller) as a JSON string. I would be able to present the fields nicely on create, but on update it would be a hassle to populate those fields (maybe) and a search function would not be very efficient with this alternative.
So what I'm looking for is a third alternative so I can fix my problem. What would be an efficient way to solve this problem and be able to have categories with different input fields and also be able to efficiently perform searches on these categories?
The project I'm working on is being created in Ruby on Rails 4 and the database is in MySQL.
For given scenario I would:
create table categories to store each category
create table category_fields to store each category field
create table collected_categories to store all collected data from category fields in serialized hash
Collected data can be easily (de)serialized into text column (no matter of db engine you will use).
Check those sources which utilize your problem: dynamic forms