Results 1 to 13 of 13
  1. #1
    fnem is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    19

    Create multiple records automatically

    I have a lawncare database that assigns a job to a customer.
    Each customer may have multiple lawns.
    Each job contains multiple tasks, each task being for a given lawn that the customer may want treating. They may want all of their lawns treating, or just some of them.



    I am able to create these tasks for the given lawns through use of a subform that assigns a task ID to a given lawn (chosen via combo box) and then links this to the Job ID. I find however that I have to create a new task for each lawn, one at a time.
    I would like to automate this in one of two ways:

    1, Allow quicker selection of required lawns using check boxes or similar and then create multiple tasks for these lawns all linked to the given job
    or
    2, provide an 'all' option on the combo box to immediately select all the customer's lawns (this will account for the majority of jobs) and create multiple tasks for these.

    Any pointers or help greatly appreciated, I'm a newb.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    make a form with a listbox of Tasks. (tTasks table)
    dbl-click the task to add them to a tPicked table. (append qry)
    then select a customer (combo) on the screen as the target.

    make a button to Post these tasks to the Clients tasks table, this button will fire an append query to add all the Tasks from the tPicked table to the Clients task to do table. They all get added at once.
    then just change customer combo to change target customer.
    add or delete an item from tPicked table if needed if a different customer has slightly different tasks.
    Last edited by ranman256; 02-02-2021 at 08:51 PM.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Can you show us your tables and relationships? Or a copy of your database with a few records to show us your forms/queries in context?

  4. #4
    fnem is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    19
    A lot to get my head around there. Thanks, I'll have a look at this.

  5. #5
    fnem is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    19
    Quote Originally Posted by orange View Post
    Can you show us your tables and relationships? Or a copy of your database with a few records to show us your forms/queries in context?
    I've uploaded a copy of the database relationships as they stand, I can't upload the database as small though it is it exceeds the 500kB maxClick image for larger version. 

Name:	Relationships.jpg 
Views:	33 
Size:	107.9 KB 
ID:	44101

    Many Thanks

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    I can't upload the database as small though it is it exceeds the 500kB max
    "Compact and Repair" the db, then zip it. Should be small enough then to post.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    fnem is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    19
    Quote Originally Posted by Bob Fitz View Post
    "Compact and Repair" the db, then zip it. Should be small enough then to post.
    Thanks for your guidance Bob.Lawncare Database 02-02-21.zip

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    fnem,

    Where exactly in the life of this database are you at the moment? Seems you have something operational that is helping support your business, but that may have some shortcomings/cumbersome processes.

    I am attaching a revised graphic of your tables and relationships --- extended all tables to show all fields, and rearranged things to reduce the number of crossed lines.

    Have you tested your current model/structure against your requirements? Do you have a list of scenarios that you can "exercise" against your current structures without actually physically writing code?

    You have gone to a very detailed physical set up, named your fields well (no embedded spaces) and tables seem to cover a broad scope of the business.

    You know your business and requirements better than any reader so responses may seem more generic and high level than you require.

    As for creating several records at one time, a typical approach would be to have a combo box and a listbox(es) and some code.
    The combo box may contain Customers, and listbox may contain CustomerLawns, another listbox may contain Tasks/Treatments. You select a particular Customer; then select 1 or more of that Customer's lawns and then select the Tasks/Treatments for each of the selected lawns for the selected Customer. Some event code (eg button click) then iterates over the selections and executes SQL to insert records for the relevant combinations. Of course there would be some validation logic to ensure selections have been made.

    Good luck.

    Click image for larger version. 

Name:	LawnCareRelationships_Rev1.PNG 
Views:	32 
Size:	78.2 KB 
ID:	44104

  9. #9
    fnem is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    19
    Hi Orange,

    Thank you for your reply.

    I use commercial software for my business currently but find it both expensive and cumbersome and have convinced myself that I could make something in Access that would fulfill my needs better and with no ongoing costs. I have thought through a number of operational scenarios and the database you see is my first draft attempt at organising the structure to accommodate these. I am trying to think through my requirements before commencing the work but realise that my own ability may limit what I can achieve with the database and also find the process of construction helps stimulate fresh ideas.

    As a relative novice but with some understanding of database principles I welcome all and any advice as well as any resources that might help a beginner such as myself build up a better knowledge of how to manipulate Access.

    Regarding the questions I posed, I currently create the Job ID when I open a new form from the Customer form, the Customer ID is passed to this and the lawns owned by the customer are shown in a subform via combobox. I select the lawns I want to be included in this job and each is assigned a Task ID and attached to the job. This is all a bit laborious though and it would be much slicker to just click 'All lawns' and create tasks for all of the customer's lawns and/or select the lawns from radio buttons or similar rather than multiple combo boxes.

  10. #10
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    the lawns owned by the customer are shown in a subform via combobox. I select the lawns I want to be included
    Red flag - tells me you're using multi value fields yet I see no indication of that in the relationship pics. I say that because unless I'm losing it, you can't multi select from a combo unless that combo is bound to a mvf.

    You might want to consider having this done professionally and incur a reasonable one time cost if this is going to cause you to take time away from the business you need to support. I imagine that even if lawn maintenance is delayed because of snow, you do snow plowing (which you could incorporate into this db) or need to focus on getting new contracts for the spring.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    fnem,

    Regarding the questions I posed, I currently create the Job ID when I open a new form from the Customer form, the Customer ID is passed to this and the lawns owned by the customer are shown in a subform via combobox. I select the lawns I want to be included in this job and each is assigned a Task ID and attached to the job. This is all a bit laborious though and it would be much slicker to just click 'All lawns' and create tasks for all of the customer's lawns and/or select the lawns from radio buttons or similar rather than multiple combo boxes.
    I made a mock up based on your first post #1 yesterday. I worked from a simple model, guessing some things about Job, Lawn, Task and Service. I then generated a database from the model (trying to understand some software I only use now and then). I realize it is a much simpler model than your business entails.

    Click image for larger version. 

Name:	LawnCareServiceMockUpDraftModel.PNG 
Views:	29 
Size:	25.8 KB 
ID:	44108

    I have a test form to demo how one could create multiple records.

    Click image for larger version. 

Name:	LawnCareFormForTesting.PNG 
Views:	27 
Size:	16.3 KB 
ID:	44109

    The process is on the record of Customer I show
    -the lawns he/she owns in a combobox
    -the general list of tasks in a listbox

    1 get the customer record you want
    2 in lawns combo select a lawn for which tasks will be performed
    3 multi select the tasks for this lawn
    4 press the Assign Tasks button
    This will create a JobId for this customer for this lawn and these actions. It also inserts records into LawnCareService table.

    5 Select another lawn for this customer
    6 Since same customer in this session get new JobId (how are jobs identified if Customer has multiple lawns and many need work??? same JobId or separate for each lawn??)
    7 multi select tasks for this lawn
    8 press the Assign Tasks button

    These sql statements are executed when the assign task is clicked with appropriate selections.

    INSERT INTO Job(CustomerID) values(1);
    INSERT INTO LawnCareService(JobID, LawnID, TaskID, ServiceDate) Values(20,4,3,#03-Feb-21# );
    INSERT INTO LawnCareService(JobID, LawnID, TaskID, ServiceDate) Values(20,4,1,#03-Feb-21# );
    INSERT INTO LawnCareService(JobID, LawnID, TaskID, ServiceDate) Values(20,4,2,#03-Feb-21# );
    INSERT INTO LawnCareService(JobID, LawnID, TaskID, ServiceDate) Values(20,4,6,#03-Feb-21# );

    INSERT INTO Job(CustomerID) values(1);
    INSERT INTO LawnCareService(JobID, LawnID, TaskID, ServiceDate) Values(21,2,4,#03-Feb-21# );
    INSERT INTO LawnCareService(JobID, LawnID, TaskID, ServiceDate) Values(21,2,6,#03-Feb-21# );

    INSERT INTO Job(CustomerID) values(3);
    INSERT INTO LawnCareService(JobID, LawnID, TaskID, ServiceDate) Values(22,5,3,#03-Feb-21# );

    INSERT INTO Job(CustomerID) values(4);
    INSERT INTO LawnCareService(JobID, LawnID, TaskID, ServiceDate) Values(23,6,4,#03-Feb-21# );
    INSERT INTO LawnCareService(JobID, LawnID, TaskID, ServiceDate) Values(23,6,2,#03-Feb-21# );

    INSERT INTO Job(CustomerID) values(4);
    INSERT INTO LawnCareService(JobID, LawnID, TaskID, ServiceDate) Values(24,6,6,#03-Feb-21# );


    Those in blue are for Customer 1 one lawn and related tasks for that lawn.
    Those in this color(middle brown) are also for Customer 1, different lawn, separate tasks
    Those in orange are customer 3, new jobID, single lawn and single task
    Those in this blue are for Customer 4, new Jobid, single lawn, 2 tasks
    Those in this purple are for Customer 4 but this as in a new session ,so he gets new JobId,single lawn, single task.

    Hope it's useful.
    Good luck.
    Last edited by orange; 02-03-2021 at 03:51 PM. Reason: spelling

  12. #12
    fnem is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    19
    Thank you very much for taking the time to provide such a detailed response. You have a slightly different structure to what I have in mind but the principle is just the same. Plenty to go on there and I'll definitely be having a fiddle with this over the weekend to see if I can get something working. Much appreciated!

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Happy to help.
    I'm attaching the code that is behind the Assign Tasks button. You may get some ideas from the code that will allow creating multiple records "automatically".

    This code is slightly modified to that used with post #11. Here, if the Customer has multiple lawns and multiple tasks for each, and this is all in 1 session of Access, then I put the multiple lawns and their multiple tasks in 1 JobId. I'm not sure what your intent is/was.

    Good luck. with your project.
    Attached Files Attached Files

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-17-2017, 11:52 AM
  2. Replies: 2
    Last Post: 03-16-2017, 05:50 AM
  3. Replies: 16
    Last Post: 02-06-2013, 09:23 AM
  4. Create Multiple Records
    By Meccer in forum Access
    Replies: 3
    Last Post: 02-03-2011, 09:33 AM
  5. Create multiple records with 1 form?
    By bergjes in forum Forms
    Replies: 4
    Last Post: 04-14-2010, 06:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums