Results 1 to 8 of 8
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    Compound in a DLookUp function

    In these three formulas for the Ceil tutorial found here:



    http://www.functionx.com/access/appl...ns/ceilinn.htm

    one of the formulas is:

    =IIf(IsNull([RoomNumber]),"",DLookUp("RoomType","Rooms","RoomNumber= '" & [RoomNumber] & "'"))
    If one were interested in BedType or Rate then simply substitute that term for RoomType.



    Now I am somewhat familiar with how DLookUp works. In other words get RoomType from a table Rooms where there is a given RoomNumber.

    Where I get confused is the last clause:

    "RoomNumber = '" & [RoomNumber] & ""

    I realize it is a compound statement hence the &, but it uses two &s and more. Please explain what they are.


    Any help appreciated. Thanks in advance.

    Respectfully,


    Lou_Reed


  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Parameters for a text field require apostrophe delimiters. The second & is to concatenate the closing apostrophe, which is seen in the IIf() expression but not in your extract.
    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
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    for this dlookup to work, the roomnumber datatype must be text - which needs to be surrounded with single quote marks (highlighted red)

    "RoomNumber= '" & [RoomNumber] & "'"

    if roomnumber datatype is actually number then the code would be

    "RoomNumber= " & [RoomNumber]

    you can check your datatype in the Rooms table.

  4. #4
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I have copied from the Ceil Inn tutorial shown here

    http://www.functionx.com/access/appl...ns/ceilinn.htm

    and I have copied these formulas from the tutorial exactly. It is still not working.

    I do not there is any variable undefined here.


    Maybe if I try and make the RoomNumber datatype a number instead of text and use
    the second formula.

    I see what happens.


    Respectfully,


    Lou_Reed

  5. #5
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    It is still not working.
    not helpful, your question was about the '&'s - perhaps you are trying to find a room that does not exist or the roomtype is blank

  6. #6
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    It does work! I spoke too soon. It just works in a way that I did not expect.

    Let me explain:

    Working on the NwOccupancy Form:

    I type in employee number and the employee name pops up in the assigned space next to it, instantly.

    I type in customer number and the customer name pops up in the assigned space next to it, again instantly.

    I type DateOccupied and nothing happens - I did not expect it would.

    I type in Room Number on the NewOccupancy form and again nothing happens. I expected it would
    show all information about the room. It does not.

    However, if I then open the Occupancy form all of the info is there - all of it. Even the room info is there.
    it is just not in the NewOccupancy form.

    The room rate, room type, and bed type are all there - on the Occupancy form. As I said they are missing on the
    NewOccupancy form. This outcome makes me question what is supposed to pop after an identifying number (Employee #, Customer Accnt. #
    and Room Number is typed.

    As I said on the NewOccupancy form the first two inputs work and the third one does not - go figure.

    Also, the Occupancy Table is missing any and all info that should be there once the room number is known.

    What should pop and why (also how do you make it popup it currently does not) when you type in a some
    identifying number?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou_Reed

  7. #7
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    sorry, I am not familiar with the Ceil tutorial and do not have time to investigate it. So no idea what should pop up and why - I would have thought that is something the tutorial would take you through (perhaps later) or it is for you to decide what you want to pop up and write the code accordingly

  8. #8
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I got it to work, but by the most indirect route.

    It is true that typing in the room number would not allow an immediate popup on the NewOccupancy Form.
    There is nothing in the tutorial that says it should, it is just that it happens on the previous two inputs when relevant info
    pops up after an Employee ID number or a Customer Accnt. number is input.

    Inputting the room number next at first evinces no pop up output. It is all on the Occupancy Form, however, and if one continues to the
    next data input on the NewOccupancy form and input data, and then steps back one data point, the output is now there.

    I do not know why it works; in the Ceil Inn tutorial its is clear when these popups occur because they are correct
    and relevant.

    Why in the world they do not all work instantaneously is a mystery to me. I try to find out why.


    Respectfully,


    Lou_Reed

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

Similar Threads

  1. Trouble with Compound Query
    By bxdobs in forum Queries
    Replies: 3
    Last Post: 02-20-2015, 11:42 AM
  2. help creating compound interest form using loops
    By cc.caroline15 in forum Programming
    Replies: 5
    Last Post: 01-28-2015, 12:20 AM
  3. Replies: 2
    Last Post: 08-10-2012, 02:11 PM
  4. Rename cell based on duplicate compound key
    By luckycharms in forum Access
    Replies: 1
    Last Post: 04-23-2012, 06:18 PM
  5. Creating Compound summations etc.
    By ohthesilhouettes in forum Queries
    Replies: 2
    Last Post: 06-19-2011, 12:29 PM

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