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.
Related
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.
I have two tables in my database..one is candidates_details and another one is users..in the users table i have two types of users one is vendor and another one is user..they both have same user_id column...and i have that user_id column in my candidates_details table..
So what i want to do is when vendor post candidate_details by using form ..i want to store that user_id
(where user_type_id=1)
in candidates_details table automatically..
Can anyone help me..Thanks in advance..
Let me help you out by giving a pictorial example. Assume you have two tables users and candidate_details. In users you are keeping record of all the registered users along with their types. In Candidate Details you are keeping their profile data. You create another table where you keep user types Be it vendor, contractor, supplier etc.
Now when you create your form to post data in your admin panel or which ever interface you have. Just create a dropdown for user_types, get the type id and add the user. With the type id in your users table you can easily query which type of user that is.
Now for saving that user's profile information in candidate_details table you only have to provide user_id. So creating one more table will normalize your db schema and saves a lot of hustle in your query building.
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?
I have a question on databases and how information is displayed in regards to Primary and Foreign keys.
For example, there are three tables; Employees, Employee_tickets and Employee_comments.
Each employeecan have multiple tickets and also multiple comments. A foreign key is placed in the Employee tickets and Employee Comments table. My application is built in vb.net with Visual Studio and it is a desktop application. How can I query say.. Employee Name ('Jon Doe') and display all of his tickets in a grid as well as all of the comments people have made on him over time? I have created a View on the sql database which returns all of the information I require but for each ticket listed under ('Jon Doe') the View displays and Employee Name for every single ticket. Is there a way to display the employee name only once and then every ticket listed under that particular individual without displaying the Employee Name again or do I have to make Separate windows to segregate all of this?
This seems like a really dumb question and I cannot for the life of me figure out how to correctly display what is required in this situation.
Here is an example of what I am trying to explain:
So for troy there is one employee name entered in the Employee Names table, There is one CWB ticket entered in the CWB table but there are TWO PQ Cards entered in the PQR Ticket table. How Can I Display only one row for Troy and one Row for his CWB because there are only one of each entered in the tables then the two rows for the PQR Cards under his name?
I have created a view which gathers this information all into the one single view itself then bound the datagridview's to this View.
Your problem has nothing to do with databases. Rather, the issue is that you have an entity (the employee) that has two separate collections associated with it (tickets and comments) and you want to show the contents of both collections.
Doing this in a datagrid is difficult because in its simplest incarnation it's intended to show one collection of like items.
I can think of a number of possibilities:
In your code, convert each collection to a single string value and display that single string value on the row with the employee's name. This conversion could be to comma-separate a stringified version of each item in the collection (as suggested by BS123 in the comments) or could simply be a summary (eg "5 Tickets").
Put the basic employee information in one data grid and then have two additional data grids below it, one bound to the Tickets collection and one to the Comments collection.
Embed data grids directly in the main data grid, one in the Tickets column and one in the Comments column, and bind each one to the appropriate collection in the employee.
Your database structure is correct so don't change that, you simply need to solve the issue of presentation.
What you're missing here is a controller between your view and your model. Your view is presenting exactly what it was given to present - it's up to you to format it.
There are several possible solutions to this, and the correct one partially depends on needs and infrastructure.
If you infrastructure is solid and your needs are near real time, consider dropping separately querying to fill your second and third tables based on what is picked in the first. This will increase the load on the database, but your data will almost always be correct, and the data will come from the database the way you want to see it.
If the database-centered solution is not good for you, LINQ provides some good ways to filter your data into typed collections that would present exactly what you want the user to see.
To get the users:
Dim users = From l In data.lines
Group By FirstName = l.firstName, LastName = l.lastName
Into Tickets = Group, Count()
You can then present this object to your grid. While dynamic typing works here, I think it would be easier to manage view interactions with defined classes. I'll leave that part up to you. Do some searching on LINQ to fill in the rest of the blanks. It's pretty neat stuff.
I have an Access DB that stores sales data for a small business. Each sale is recorded as a record in the "Sales" table. For each sale, the item name and customer name are stored, along with some other information.
There is also a "Customer" table and an "Item" table, which contain all valid customers and items, respectively. If the user attempts to import a record that contains a customer that is not listed in the "Customer" table, this record is not imported; similar situation with items.
I would like to change this so that if the user attempts to import a record that contains a new customer or item, then the user is notified of this (e.g. "A new customer, Adam Smith, appears in one of the records you are trying to import.") and then given the option to add this new customer.
I realize that this is probably not good practice, but does anyone know of a quick way to add this functionality?
[Information regarding the import feature: The user's sales data is stored in an Excel workbook. To import new sales data, the user uses a form that I built that allows him to select a file to import and then imports the data into the proper table. This is implemented in VBA.]
Thanks!
You could link the Excel table, run a query that shows up new customers in a form. You can then ask the user to either match to an existing customer or create a new customer. The added records could be flagged as incomplete, if necessary, and the user could be asked to add relevant details at a suitable point.
Most of this can be accomplished with queries, for example, adding customers to the customer table can either be done with an append query or by writing the relevant data to the customer table by using fields in the review form.