Results 1 to 11 of 11
  1. #1
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154

    Dlookup in Report

    I have some trouble in using the Dlookup

    I have a table - Hotel address to keep all hotel address

    I want to prepare a voucher for my guests
    when i selected the hotel, i need to fill the address from the hotel address

    But i get an error i wonder where want wrong



    Please kindly help

    Click image for larger version. 

Name:	Hotel_vhr.JPG 
Views:	13 
Size:	59.7 KB 
ID:	30978Click image for larger version. 

Name:	Htl_address.JPG 
Views:	13 
Size:	32.3 KB 
ID:	30979

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    [Htl_address] needs to be in double quotes

  3. #3
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    I tried

    =DLookUp("address","[Htl_address]","hotel=" & [Hotel])

    =DLookUp("address","Htl_address","hotel=" & [Hotel])
    Stil not working


    Click image for larger version. 

Name:	Capture1.JPG 
Views:	12 
Size:	21.2 KB 
ID:	30980

    Click image for larger version. 

Name:	Capture2.JPG 
Views:	12 
Size:	16.6 KB 
ID:	30981

  4. #4
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Any idea ?!

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    OK so Hotel is a text value, not an ID (i.e. a number)

    So try "Hotel='" & me.Hotel & "'"

    If that doesn't work is the spelling correct for Htl_address? and does the table contain fields called address and hotel?

    Also, is the control where the hotel is typed called Hotel? and not txtHotel or something else?

    Otherwise it would appear that your field Hotel in Htl_Address is a lookup field - which displays text but stores a number (the ID)

  6. #6
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Ajax

    Can you help me out , i still unable to solve the problem

    I tried to find the hotel address from htl_address form or
    table in the Query.

    addlookup("add","htl_address", "add='&[address])

    But fail.

    Any where i did wrong?!

    Eric
    Attached Files Attached Files

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    There is no Hotel_vhr report in that db.

    The Hotel field in Update_25_11 is a text type. It should be a number type and save the ID from Htl_address.

    Then build query that joins 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.

  8. #8
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    June 7

    The Hotel field in htl_addresss and the Update_25_11 are all in Text type, as it is for hotel name ..

    i tried to link the Hotel field of both update25 and htl_address , it links


    But i want to do it in Dlookup, it seems to be that Dlookup i have some syntax error that i am unclear

    Can you help to correct me ?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Should not be saving the hotel name, should be saving the hotel ID.

    Regardless, DLookup() is the least efficient method to pull related data. Domain aggregates can perform slowly in query and textbox. Why don't you just build a query that joins the two tables and use that as the report RecordSource?

    Dlookup("address", "htl_address", "Hotel='" & [Hotel] & "'")
    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.

  10. #10
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    fort some reason the OP keeps changing names - there is not a field called 'add'

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Thanks Ajax. I meant to use "address", edited my post.
    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. DLookup In Report only showing on first line
    By crimedog in forum Reports
    Replies: 11
    Last Post: 04-09-2015, 07:55 AM
  2. Replies: 1
    Last Post: 11-14-2014, 05:12 PM
  3. Replies: 5
    Last Post: 06-27-2013, 02:49 PM
  4. Dynamic crosstab report sorting headings & dlookup
    By chrisangk in forum Programming
    Replies: 9
    Last Post: 01-14-2013, 02:37 PM
  5. Using Dlookup in unbound text box in report
    By PrintShopSup in forum Reports
    Replies: 3
    Last Post: 12-27-2010, 10:29 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