Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    bronson_mech is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    94

    Dlookup function Help

    i have 2 tables 1)tblEmployee in that (Empname,Company,jobtitle, Reg HrsRate, Ot HrsRate)...... 2) Work Hours Subform in that( Empname,Company,jobtitle, Reg Hrs, Ot Hrs,Reg HrsRate, Ot HrsRate) here i need to get Reg Hrs Rate from table1 & input in Work Hours subform Reg Hrs Rate Using Dlookup Function......

    i Tried

    Private Sub Emp_Name_AfterUpdate()
    Regular HrsRate = DLookup("Regular HrsRate", "tblEmployeesRate", "Empname=" & Empname)


    End Sub

    but its not working.......

    pls help me to fix this................

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I suspect this is what you're trying to do:

    BaldyWeb - Autofill

    If you want to stick with the DLookup():

    DLookup Usage Samples

    Noting the syntax for a text field, plus the inadvisable spaces in your names will usually require them to be bracketed.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    EddieN1 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    316
    You need double quotes (chr(34)) around empname... try

    Regular HrsRate = DLookup("Regular HrsRate", "tblEmployeesRate", "Empname=" & Chr(34) & Empname & Chr(34))

  4. #4
    bronson_mech is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    94
    its not working.............

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Just curious: why do you have so many fields duplicated in the two tables? All you should need in the WorkHours table is the EmployeeID.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quote Originally Posted by RuralGuy View Post
    Just curious: why do you have so many fields duplicated in the two tables? All you should need in the WorkHours table is the EmployeeID.
    +1 on that. Also what's not working exactly? Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    EddieN1 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    316

    +1 question

    What about changing Reg HrsRate to [Reg HrsRate]... Eddie

    What is value of "empName". If it contains double quotes, that will be a problem...

  8. #8
    bronson_mech is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    94
    only 1st line item value is displaying even if i select different value from combo box

    Private Sub PIR_MOC_AfterUpdate()
    WO = DLookup("WO", "tblProjectDetails", "ID=" & "ID")
    End Sub

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Were there quotes around the value in the link I posted?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    bronson_mech is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    94
    in pic 1 ..........if i select pir/moc it should give output in wo but if i take that quotes its giving me an error.......
    Click image for larger version. 

Name:	1.jpg 
Views:	10 
Size:	93.6 KB 
ID:	12964Click image for larger version. 

Name:	2.jpg 
Views:	10 
Size:	110.5 KB 
ID:	12966Click image for larger version. 

Name:	3.jpg 
Views:	10 
Size:	91.2 KB 
ID:	12967

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Your field does not appear to be named "ID", and the error shows no value. Perhaps it should be:

    DLookup("WO", "tblProjectDetails", "ID=" & Me.PIR_MOC)

    But the method I posted earlier is more efficient than the DLookup(), and simpler IMO.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    bronson_mech is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    94
    Again 1 error
    Click image for larger version. 

Name:	4.jpg 
Views:	12 
Size:	96.2 KB 
ID:	12968

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Is there a reason you don't just get the value from the combo row source? Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    bronson_mech is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    94
    i can't able to upload......"upload failed".......... can u pls give me ur mail id , i'll send it through mail...........

  15. #15
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    1st Compact and Repair your db. Then ZIP it up. That will allow you to attach it to a post. The limit for zip files is 2MB.

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

Similar Threads

  1. Dlookup Function
    By MarkHenderson in forum Queries
    Replies: 1
    Last Post: 11-19-2012, 03:00 PM
  2. DLOOKUP function
    By tariq1 in forum Programming
    Replies: 5
    Last Post: 07-17-2012, 04:22 PM
  3. DlookUp Function.
    By cap.zadi in forum Forms
    Replies: 11
    Last Post: 09-22-2011, 12:56 PM
  4. using the and function in a dlookup statement
    By englisap in forum Programming
    Replies: 10
    Last Post: 01-10-2011, 09:53 PM
  5. Need Help for Dlookup function
    By wasim_sono in forum Programming
    Replies: 5
    Last Post: 01-04-2006, 08:18 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