Results 1 to 12 of 12
  1. #1
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92

    Need help with creating query & form

    Hi everyone. I’ve run into a situation with my database that I’m not sure how to solve.

    First, a little background on what I’m doing: I’ve created a database to electronically handle some employee paperwork, so that my employees don’t have to fill it all out each time they do a job with me. (I work on Film/TV productions, and I do many different jobs each year. The crew members have to fill out the same paperwork every time, and it’s a bit of a pain.) That part of the database is done and works great. I now want to add their timecards to the database, both to help me with the calculations of them and to be able to do them paperlessly. I’ve created the Table for the Timecards, but am now trying to create the Form, and I’ve reached a point where I’m not sure how to do it. I guess I don’t understand how database tables relate to one another well enough, because I can’t seem to figure out how to properly create the combo boxes that I want.

    I know it would probably be helpful for you to be able to see my table relationships, so I’ve created a PDF laying it all out. You can find it here:
    https://www.dropbox.com/s/7iptj64eoc...ships.pdf?dl=0



    Here’s what I’m trying to do on my Timecard form:
    - First, I want a combo box that allows the user to specify which Job the timecard is for. (This should be a combination of the job name followed by the company name who is producing the job. I’ve done a combo box that combines the two on one of my other forms, and it works, but here it’s a bit trickier, as I’ll explain below.)
    - Next, I want a combo box where I can select which employee the timecard is for, but I only want the combo box to list the employees that are currently working on the particular job that has been selected in the combo box above. Employees are “assigned” to a job on the EmployeesOnJobs table.
    - Then, I want certain information about that employee to automatically fill in on certain areas of the form. That information would be pulled from the EmployeesOnJobs Table and the various tables that have relationships with that table.

    I have created a query to make this Timecard form with, and I have included the various items from the different Tables that I would need. However, I can’t figure out how to create those first two combo boxes that I mentioned. (I know how to create combo boxes in general, but I don’t know what my Control Source and Row Source should be for these.)

    I hope this is clear. It’s definitely getting complicated for me. I'm sure this is due to my limited knowledge of how databases/Access works. I’d really love to try to understand it so I can add this functionality to the database. Anyone able to explain how I would do what I’m wanting to do?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Sounds like you need cascading (dependent) comboboxes. This is any extremely common topic. Search forum and web.
    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
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92
    Thanks. I'll search around and see what I can find.

  4. #4
    Join Date
    Apr 2017
    Posts
    1,776
    Here is one possible way to do this
    Attached Files Attached Files

  5. #5
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92
    Quote Originally Posted by ArviLaanemets View Post
    Here is one possible way to do this
    Wow... I can't thank you enough for spending the time to make this. It's VERY helpful. I will probably have questions about it, and if so, I'll pop them here. Thanks again!!

  6. #6
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92
    I'm trying to create my own SQL statement for the filtering of a third combo box to choose the correct Position Title of the Employee (in case the person works two positions on the same job, which occasionally happens), and I am getting a syntax error. I can't figure out what is wrong with the statement. Any ideas?

    Code:
    Me.PositionComboBox.RowSource = "SELECT PositionID, PositionTitle " & _
                                    "FROM "[Q_Employees on Jobs] " & _
                                    "WHERE JobID = " & Me.JobNameComboBox & " AND EmployeeID = " & Me.EmployeeNameComboBox & " " & _
                                    "ORDER BY PositionTitle;"

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Remove the " after FROM
    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.

  8. #8
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92
    Wow. I can't believe I didn't see that. Thank you. I guess after staring at something for so long, sometimes you just can't see what should be so obvious!!

  9. #9
    Join Date
    Apr 2017
    Posts
    1,776
    I haven't access at home available, so I can't check it currently.

    In my example db I assumed en employee can have only one title on job. When you look at indexes, there is defined an unique index based on JobID and EmplID. When employee can wear several hats at same job, the whole setup must be corrected - starting with adding TitleID to unique id. But probably you don't need a 3rd combo - you simply have to edit the second one so that it displays title for employee too - i.e. whe an employee has 2 titles, the user can select the same employee with either of them. The second combo returns not EmplID, it returns ?RowID, and in this case the employee has 2 different rows in table (don't remember what names I used for tables and fields, and can't look up them!).

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Happens to the best of us

    Something to think about is a common practice for identifying control or data types or objects is to use a 3-letter prefix, such as cbxEmpID, tblEmployees, frmEmployees, etc.
    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
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92
    Quote Originally Posted by ArviLaanemets View Post
    I haven't access at home available, so I can't check it currently.

    In my example db I assumed en employee can have only one title on job. When you look at indexes, there is defined an unique index based on JobID and EmplID. When employee can wear several hats at same job, the whole setup must be corrected - starting with adding TitleID to unique id. But probably you don't need a 3rd combo - you simply have to edit the second one so that it displays title for employee too - i.e. whe an employee has 2 titles, the user can select the same employee with either of them. The second combo returns not EmplID, it returns ?RowID, and in this case the employee has 2 different rows in table (don't remember what names I used for tables and fields, and can't look up them!).
    Good idea about the 2nd combo box displaying both the Employee name AND their Position title! I think I can figure out how to do that. If not, I'll post back here.

  12. #12
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92
    Quote Originally Posted by June7 View Post
    Something to think about is a common practice for identifying control or data types or objects is to use a 3-letter prefix, such as cbxEmpID, tblEmployees, frmEmployees, etc.
    Ah -- good to know, thanks.

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

Similar Threads

  1. Does creating a form also create a query?
    By PATRICKPBME in forum Queries
    Replies: 4
    Last Post: 04-11-2017, 06:08 AM
  2. Creating Datasheet Form from Query
    By Ekhart in forum Forms
    Replies: 11
    Last Post: 12-30-2016, 05:19 PM
  3. Creating a Form from a query
    By Lou_Reed in forum Access
    Replies: 6
    Last Post: 08-29-2015, 11:25 AM
  4. Creating a Search Form using query
    By sam.eade in forum Queries
    Replies: 2
    Last Post: 09-07-2013, 03:55 AM
  5. Query creating with form entry
    By VRimkus in forum Access
    Replies: 3
    Last Post: 04-15-2013, 11:09 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