Results 1 to 14 of 14
  1. #1
    gastoff is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    7

    Question Using CommandButton to add Fields to a Form

    I am trying to build a form that will serve as a timesheet and equipment tracker for end users.


    Since the end user will have zero experience with Access, I am trying to make the form as intuitive and streamlined as possible.
    The end user will be a foreman/jobsite supervisor that will need to input his crew members hours and equipment usage on a daily basis.

    Using the CreateControl(acComboBox) command, I figured out how to insert a combo box at a desired location on my form, but is there a way to insert another combo box below the existing one using the same command button?

    Im envisioning a form that has an "Add Employee" button that can be clicked and will create a combobox (fields to enter start/stop time will also be generated), and when clicked again, will add another combobox below the initial one, and so on for each employee.

    Is it possible to have a CommandButton key off of the objects it creates to make a dynamic form?

    I should probably throw out the caveat that I am a novice when it comes to vba...I've been using google to try and teach myself what I can, but I've run into a wall on this one.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,641
    I suspect your db is not normalized. A process that requires routine modification of design is not optimal. What you want requires opening form in design view, do the mods, and then saving the new design. This can be done programmatically but is a bad idea.

    A time and attendance db is one of the more difficult to build. This is because 'timesheet' paper forms seldom resemble normalized data entry form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    gastoff is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    7
    Instead of building a button that adds new fields to the form as it is clicked, would it be easier to have a bunch of unpopulated fields that are set to not being visable, and have a button that reveals one at a time?

    I am trying to avoid having a final form that has 15 blank fields for employee entry if only 3 people worked that day. But since the employees per day will shift and could reach as many as 15-20 for any one job, I will need the final result to be capable of having entry for everyone if needed.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    What I usually do is create new records vs. creating a new field/column.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,641
    You need a db structure that allows form design for creating records, not fields. This would mean a combobox that lists employees to choose and a textbox to enter the hours.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    gastoff is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    7
    The form I am creating will not be used to add new records. On the backend, I have separate tables for employee records, equipment records, and Active/Inactive Jobs.
    The end user that will be using the final form will not have to add any new records. I am trying to build a form that they can use dropdown boxes for almost everything...the end users are construction foremen/supervisors that will likely have limited experience with Access/Excel or even computers, so it needs to be user friendly and almost entirely point-and-click interaction.

    Since each foreman may work on multiple jobs in a day that have changing crews and equipment, I am attempting to design a sheet that will allow them to add employees one a time from a dropdown menu. After selecting an employee, they can add that employee's time for the project, any equipement used, and then move on and input another employee's time.

    After inputting employee and equipment times, a "Submit" button at the bottom will export all the inputted data and send it off to HR for payroll processing and job cost allocation.

    Am I going about this the right way or is this dynamic timecard concept too much for Access to handle?

  7. #7
    gastoff is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    7
    Here is a snapshot of what I'm working on so far:
    Click image for larger version. 

Name:	Preview.png 
Views:	18 
Size:	31.7 KB 
ID:	22358

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,641
    What you want could probably be done but will likely involve a LOT of VBA.

    I think it would be easier to build a normal db and educate the users. I suspect they know more than you give them credit for.

    You already have them selecting employee from dropdown - that really isn't any different from what I describe.

    What do you mean by 'send it off' - they aren't inputting data direct to central database - who does? How do you plan to 'send'? Even if this data entry isn't direct to central db, still should use tables in normalized structure to hold input.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    gastoff is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    7
    The information they are inputting on the form will collate in a backend db that payroll can draw from.
    Every day, anywhere from 10-20 project leaders/foremen are active on as many as 5 projects each, and they have dynamic crews each day. Sometimes, they may swap crews multiple times each day. The same hold for equipment. Each piece of equipment may be use on multiple projects each day: the same dump truck may haul material to 20 sites in a day, etc.
    Each project will be tracking equipment and employee times each day, so my final time card will need to be dynamic as every day will have its own unique makeup of crews/equipment.
    The crew leaders for most projects have been fieldmen for the last 15-20 years and are more comfortable with a shovel in their hand than a laptop, so the final system will need to be streamlined.

    I can build the layout pretty well and know how I want everything to link up in the background. Im just wondering if there is a way to use VBA to add blank input fields, that way I dont have 20 blank rows filling up a page that may go unused.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,641
    With a normalized db, there would not be '20 blank rows' - there would be only 1 - the NEW RECORD row.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    gastoff is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    7
    I am so new to access that I guess I am just not understanding what you mean. I wish the forum allowed me to upload what Im working on so you could more easily point out where my train is derailing

  12. #12
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Read the signature for June7. I tells you how to attach files.

  13. #13
    gastoff is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    7
    Here is a .zip of my db.
    Attached Files Attached Files

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,641
    You need 2 more tables in your db. 1 for the selected employees and 1 for the selected equipment. Use a form/subforms arrangement for data entry. Review https://support.office.com/en-us/art...8-C266FE084102

    Your main form would be bound to Projects and two subforms for binding to the two new tables.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 10
    Last Post: 02-27-2015, 11:28 AM
  2. Replies: 1
    Last Post: 06-20-2013, 05:06 PM
  3. Replies: 8
    Last Post: 08-02-2012, 10:50 AM
  4. Replies: 5
    Last Post: 02-27-2012, 02:05 PM
  5. Replies: 0
    Last Post: 05-09-2010, 08:43 AM

Tags for this Thread

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