Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Ht99vpi is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Location
    Central KY
    Posts
    11

    Trying to create a relationship between 2 tables where 2 fields are look up refrenced

    Hello, I am new to this forum and have tried searching several different DB forums looking for a similarity to what I am attempting to do. I am a firefighter working on a project for my supervisor that will track our Employees shift exchanges. I have some knowledge in both access and SQL. I have created 3 tables 1 is Staff_Details which has all our staff listed. The other 2 tables are Trade_Off and Trade_Worked, they will be used with a form I will create later to allow a supervisor to enter the data for each exchange. This is what I have so far.

    Table
    Trade_Off


    Fields
    ID, Staff_Name, Date, Duration, Staff_Exchange
    Table
    Trade_Worked
    Fields
    ID, Staff_Exchange, Date, Duration, Staff_Name

    Current set up Trade_Off table is filled out with all information, using Staff_Detail table as a look up for both Trade_Off.Staff_Name, and Trade_Off.Staff_Exchange fields. I would like to have the Trade_Worked.Staff_Exchange field automatically filled out based on what is entered in the Trade_Off.Staff_Exchange field. Previous attempts have resulted in displaying the Staff_Detail.PriKey field not the Staff_name, which is what I want.
    Other attempts have ended in Key index errors when creating the relationships.

    The second thing I am ultimately looking to accomplish is to track and update the Trade_Worked.Duration field as the Trade_Off.Duration is filled out linked to the Trade_Off.Staff_Name. This is to allow us to track the hours of the shift exchanges for each employee and verify remaining hours for each employee for each trade.

    The initial Trade_Off will not have a date selected for the Trade_Worked table for repayment of the Exchange this will be added later when it has been identified.

    I am open to any other options for accomplishing the same task if anyone has any thoughts. I can also provide any additional details if needed to understand my goal or what I have already done.

    Paul

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If Jim Jones wants 12 hours off, can Susie Smith work 6 hours and Bill Brown work 6 hours? Or is the exchange 1 person to 1 person?

  3. #3
    Ht99vpi is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Location
    Central KY
    Posts
    11
    The pay back of the hours is 1 to 1 but it can be split up among several people. So Jim Jones will have to work for Susie Smith 6 hours some other time and Bill Brown will need to do the same.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    This is really rough. It is in Acc2000 - I can convert it to Acc2010 tonight if it doesn't work for you.

    When you open the dB, it should open to a form to add shift exchanges. There is also a form to add new staff - just names....

    How close is this??

  5. #5
    Ht99vpi is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Location
    Central KY
    Posts
    11
    That is almost perfect but the column for remaining hours is not displaying any data. I can fine tune the rough edges. This will save me many frustrating hours. Thank you. Do you think the problem is the difference between 2000 and 2010,as far as the remaining hours? Also how did you set up the 2 forms to be used? Is one for entering the original exchange off and the second for the pay back of the exchange?

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Yes, the top part (main form - Trade Off) is for entering the original request for time off and the bottom (sub form - Trade Work) is for entering pay back hours.

    Hmmm, the remaining hours is updating for me. I'll look at this tonight at home using A2K10...

    -----------------
    I was thinking about taking out the control (combo box) for the Staff_Exchange in the top (main form), because there could be 1 or more staff paying back.
    In the sub form (Trade Work), I was also thinking about taking out the control (combo box) for Staff_Name, but still update the table field with the Staff_Name ID since the records are linked. I'll see what it looks like tonight..

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I converted the A2K dB to A2K10 accmdb.

    That is almost perfect but the column for remaining hours is not displaying any data
    It is working for me - both versions. Are the colors being displayed?

    Attached is the A2K10 version.

  8. #8
    Ht99vpi is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Location
    Central KY
    Posts
    11
    There is still no data displaying in the Remaining hrs column. When you ask if the colors are visible, the only colors I see are the 2 buttons for close form and quit. The Set BG button does not work at all if that is what you mean. I also got an error "Run-time 2452 The expression you entered has an invalid reference to the parent property" when entering paid back time when I tried debugging it I was taken to this

    Private Sub Form_AfterUpdate()
    Me.Parent.RemainingHrs.Requery
    End Sub

    The second line was highlighted.

    See attached not sure what colors your talking about. Click image for larger version. 

Name:	Screenshot.PNG 
Views:	8 
Size:	38.4 KB 
ID:	10847

  9. #9
    Ht99vpi is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Location
    Central KY
    Posts
    11
    @ssanfu

    You have been a tremendous help. Are you still available to assist me with trouble shooting the remaining hours calculation? I have not heard back from you in several days. Please let me know so I can work toward finding a solution. Again I am very grateful for the help you have provided but I am unable to trouble shoot your DB myself because I am unfamiliar with VBA.

    Paul

  10. #10
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Sorry. I didn't see your response after my last post.

    See my post #8. Have you tried it? I converted it to the A2K10 version. The remaining hours shows the hours - no errors for me.
    If you just open my example, are there errors? Are the remaining hours displayed?

  11. #11
    Ht99vpi is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Location
    Central KY
    Posts
    11
    No problem, just didn't know where to go from here. I did receive your last DB converted to 2010, and it did not produce numbers in the remaining hrs column. I received no errors when opening the DB but did receive an error when entering a new record as noted in my #8 post. The attached picture is what the form looks like.

  12. #12
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Would you send back the "ShiftExchangeDemo2" copy you were testing? I'll look at it tonight.
    The remaining hours field is not showing up??

  13. #13
    Ht99vpi is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Location
    Central KY
    Posts
    11
    I have attached a picture of the error i am getting and highlighted the row I added when I received the error. Also I am not seeing anything in the remaining hours column not even a blank space. Again the error is occurring when I try to enter the pay back of some of the hours of an exchange.

    Click image for larger version. 

Name:	DB error.PNG 
Views:	8 
Size:	133.4 KB 
ID:	10984ShiftExchangeDemo.zip

  14. #14
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I'll have to look at it tonight - only have A2K at work.

  15. #15
    Ht99vpi is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Location
    Central KY
    Posts
    11
    Steve,
    Just checking to see if you were able to find anything wrong with the DB?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 10-29-2012, 11:43 AM
  2. Replies: 2
    Last Post: 08-07-2012, 01:16 PM
  3. Replies: 6
    Last Post: 03-09-2012, 01:07 PM
  4. Replies: 1
    Last Post: 03-08-2012, 09:17 AM
  5. help me create relationship
    By Candy in forum Access
    Replies: 7
    Last Post: 05-29-2010, 07:43 PM

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