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.
Related
I want to revisit a project I made to store user data into a database and improve on the way it is stored. I currently went the hard way about it and stored user data in JSON format within a MySQL database field making it difficult to complete CRUD actions. The reason I did this was to keep all the user's data within the user's field. And was reasonably new to this.
I didn't want to store the data mixed with other user's data and as I thought there may be issues with increased users. for example,
If I had 1000 users with 500 rows of data for each, that's 500 000 rows to sort through when reading the data and displaying it on a web page. And is there a risk of mixing the data up or performance issues?
I basically just want a user database that stores the user's id, name, and credentials. Then another database that will store data from a user's activity(run). So at least 5 fields for each event: Time, location, date, duration, etc. And this will be saved for different events(runs) which could end up in the 100's over a period of time.
My question is, Should I design the table as above. Or would it be better to have a table for each user? Or are there other options that I have not explored?
Given the information shared, I believe below mentioned design may be suitable.
Create a Table called User_Details with columns as id (auto increment),user id, name and credentials.
Now create a User_Activity Table with these columns id, user_id, event name, data(json field).
Explanation:
The User Activity table will store the event data for you related to each user through user_id field to user_details table. The data which is a json field will help you to store all the fields for the event. As you are using json field in DB it will allow you to dump any number of fields for the event which may/may not be structured. You can then map this in your middle layer as required.
Also, in case you have finite number of events then you can also create a table called user_event_types and have column id, event name and then in user_activity table you can refer the id instead of event name.
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.
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've been using Access to create simple databases for a while with great success, but have run into a problem I can't find an answer to.
We ship individualized serialized units to various end-users, and occasionally to resellers that stock them for end-users. I must keep track of which serial numbers end up with each end-users.
The first database I created to handle this recorded company information in one table using their account number as primary key, order information in a second table using the order number as the primary key and linked via the company name, and unit information in a third table with the serial number as the primary key and linked via the order number.
This worked very well until I had to account for these stock orders with a reseller. As it was structured, every unit was linked to one company via the sales order. The issue is that I may ship 20 units on one order to Company A, who then sells 5 to Company B and 3 to Company C.
I realized I needed to link the company name directly to the units, not the orders and have fixed that.
My issue now is simplicity in entering information in the form. My previous database involved the employee in our shipping department merely entering the sales order, selecting the customer name from a drop down menu, then scanning the serial numbers in a subform. This was to ensure simplicity and try to eliminate human error. He had only three things to input, and most of the input was done by scanning barcodes.
As it is currently structured now, the employees out in shipping would have to populate the company name for every record in the subform with the serial number and that complicates things in a way that is unacceptable. At the point of shipping, the company name will always be the same for every unit in the subform.
So.
How would I go about creating a form where the company name is entered once in the form, and automatically populates itself for every record in the subform? The caveat here is that I must also be able to go back occasionally and change the company name of individual units in an order without necessarily affecting the rest of the order. I suppose it starts out as a one-to-many relationship that then must be able to change.
I hope that makes sense.
I have looked for answers using various approaches with auto-fill and relationships and not preserving data integrity, but I feel the answer is just beyond my reach.
The only solution I can think of is to create another field in the unit table for the end-user, and perhaps write a formula that sets this default value as the company name from the order that shipped it. This seems unnecessarily complicated and redundant, there has to be a better way.
I get this data feed for a MySQL database. It will change, but there is no indication what has changed from the source. One approach to this, is create an OLD table and a NEW table. After the data feed has been populated to the NEW table, then do a comparison of the OLD table and any reasons that don't exist in the OLD table, are considered new or changed records. By the way, there is no record ID from the data feed, so I can't use that as reference.
In MySQL, how do I compare the OLD table and the NEW table, on specific fields to get a list of those that are new or changed? Thanks!
Additional information update:
The data feed is a mailing list, but there is no assigned ID for the records from the source. So some of the fields from each record would have to been compared to find a match, but display those that are not a match. The purpose of this, is to produce a report for marketing of who the new customers are to be added, or if their information has been changed.
The focus on this task is to determine what records from the data feed are new or have been changed since the last feed. The feed is done nightly. There is no database that needs to be updated, we only need a report of what is new/changed since the last feed. The key field is Company_Name.
So I need to know how to do a MySQL query to search the old table (which was yesterday's data feed) and compare it to the new table. If the Company_name doesn't exist in the new table, then this would mean this customer has been deleted from the mailing list. If Company_name exists in the new table, but does not exist in the old table, this would indicate this is a new customer added to the mailing list.
Might this MySQL work to locate new records?
SELECT * FROM old
WHERE old.company_name
NOT IN (
SELECT new.company_name
FROM new
WHERE old.company_name=new.company_name
);