Results 1 to 10 of 10
  1. #1
    ehrendreich is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    6

    Lookup in subform

    In the attachements I have my relationship diagram including all pertainate tables/fields. In addition I have a screen shot of the form in question.



    The problem I am having is performing a lookup for a wage rate. The look up must use the employeeID field to match the employeeID field in the tbleWageRate. Each employee can have a different pay rate. There are only so many type of pay rates. I have a tblWageType table. This defines these wage types and includes a type name and type description.

    I want to store the WageRateId. I want to show a list of all of the rates available to the employeeID that is listed in the main form and show the type name and description. I also want it to populate the WageRateAmount field on the form as an audit check.

    I hope that I am clear about this I have not developed in access in a long time.

    Thanks

    Bill

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So you want to change the WageRateAmount control in the SubForm to a ComboBox that looks uo the value? Where are you having a problem?

  3. #3
    ehrendreich is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    6

    The problem is

    I do not know how to send the employeeID field from the main form to the query that I am using to look up the info in the tblWageRate. It also needs to update when I move between Employee records. I have a parameter in the query called EMPID.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You have an EmployeeID field in the RecordSource of the SubForm (tblShiftMaster). I'll bet this is the LinkChild/MasterFields property of the SubFormControl and changing the Employee in the MainForm changes what appears in the SubForm.

  5. #5
    ehrendreich is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    6

    Pass EmployeeID value to query

    How can I take that employeeID value and pass that to my query?

    Basically I have no idea how to look up the rate info by employee and look up the rate type information, display all of that and store the rateid.

    I can't figure out how to do this. I suspect that VBA on Enter and Click events would to it. I would imagine that if I set the varible on the Enter event and on click used that value to call the query with the employeeID value as an arguement. I would imagine after that I would have to close the query.

    I have no idea how to do this. Maybe there is a simpler way.

    Thanks for your help on this.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Use the ComboBox wizard to create the cbo for you. It knows how do do all of that. It is all done in the RowSource of the cbo with a WHERE clause.

  7. #7
    ehrendreich is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    6

    WHERE Clause

    Using the cbo wizard I can return all of the WageRate info. I can not however filter the results so that only those that match the EmployeeID value from the main form. It needs to update this every time it goes to a new record.

    SELECT tblWageRate.WageRateID, tblWageRate.EmployeeID, tblWageRate.WageTypeID, tblWageType.WageType, tblWageType.WageTypeDescr, tblWageRate.WageRateAmount
    FROM tblWageType INNER JOIN tblWageRate ON tblWageType.WageTypeID = tblWageRate.WageTypeID;

    It does not give me a WHERE statement. Is there a WHERE statement that I can use to pass the current tblEmployeeMaster.EmployeeID record each time the combo box is clicked.

    Also it seems that once I access the combo box it allways shows the same thing. Ie it does not try to update each time it is accessed.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Add this WHERE clause to your RowSource:
    SELECT tblWageRate.WageRateID, tblWageRate.EmployeeID, tblWageRate.WageTypeID, tblWageType.WageType, tblWageType.WageTypeDescr, tblWageRate.WageRateAmount
    FROM tblWageType INNER JOIN tblWageRate ON tblWageType.WageTypeID = tblWageRate.WageTypeID
    WHERE tblWageRate.EmployeeID = Forms!tblEmployeeMaster2!EmployeeID;
    ...then Open a code window for the GotFocus event and do a Me.cboName.Requery
    ...using your ComboBoxName of course.

  9. #9
    ehrendreich is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    6
    Thank you. That did the trick. I knew there was a simple way. It has been a while.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're welcome. Glad we could be of some help.

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

Similar Threads

  1. Complex Lookup?
    By murphyB in forum Database Design
    Replies: 1
    Last Post: 09-17-2009, 12:43 PM
  2. Lookup Form
    By virgiljones in forum Access
    Replies: 0
    Last Post: 10-17-2008, 10:39 PM
  3. Lookup Form
    By cav0227 in forum Forms
    Replies: 0
    Last Post: 04-16-2007, 09:23 AM
  4. Lookup
    By neon'00 in forum Forms
    Replies: 2
    Last Post: 04-14-2007, 01:19 PM
  5. Replies: 1
    Last Post: 12-10-2005, 04:52 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