Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    sseniour is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2019
    Posts
    10
    Quote Originally Posted by Welshgasman View Post
    You are using spaces in field names and no square brackets.


    Please read any replies.

    I am using spaces in field names, but have those enclosed in brackets. Am I not supposed to do that?

  2. #17
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,574
    Quote Originally Posted by sseniour View Post
    I am using spaces in field names, but have those enclosed in brackets. Am I not supposed to do that?
    OK, was looking on my phone.
    Yes, you must have [] if you have spaces in object names. Not recommended. I use CamelCase. Some people use _ in place of the space.

    Show us the result of the Q_First.... and the SQL please.
    I would not prefix the fieldnames with the domain name, you are already supplying that. Try and keep things as simple as possible.

    Alternative, upload enough of the DB to see the issue. I myself work best when having the code to hand and test.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #18
    sseniour is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2019
    Posts
    10
    I have revamped my db as some have suggested to not include spaces in field names. My Production_Minutes table has "Time" (Date/Time field formatted as Short TIme. Also has field "ProdMins".


    Click image for larger version. 

Name:	2025-08-29_11-44-23.png 
Views:	19 
Size:	54.5 KB 
ID:	53231

    My dlookup formula is returning blanks. I'm sure it has somthing to do with formatting but just not sure what. The "CurrFUlTime" is a text field.

    many suggested to get my infomation from a formula instead of using DLookup. Will dlookup not work? Seems easier than writing formula with all the if statements? Appreicate all the feedback

  4. #19
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,574
    Your Dlookup is wrong. Date and times must be surrounded with #
    Try
    Code:
    CurrProdMins: DLookUp("ProdMins","Production_Minutes","Time = #" & CurrFUITime & "#")
    CurrFUITime should not be text, but a time datatype, else use TIMEVALUE() as I have mentioned several times.
    If it was text like a name then you surround with single quotes or triple double quotes (I think) if that could contain a single quote like O'Neil
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #20
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,822
    Can you upload a copy of the database?

  6. #21
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Date/Time type field always has a date component even if field is formatted to ShortTime. Format property does not change data. Format function does.
    You say Time field is date/time type yet CurrFUITime is text type. Have to convert Time to text or CurrFUITime to date/time. Both worked for me.

    Code:
    DLookUp("ProdMins","Production_Minutes","Format(Time,'hh:nn')='" & [CurrFUITime] & "'")
    or

    Code:
    DLookUp("ProdMins","Production_Minutes","Time=#" & [CurrFUITime] & "#")
    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.

  7. #22
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,574
    Date/Time type field always has a date component even if field is formatted to ShortTime.
    I thought that, but try putting just a time into a formatted short time field, then change it to general, then look at it.
    Code:
    ? dlookup("inputTime","Table1","ID=1")
    17:36:00 
    
    ? format(dlookup("inputTime","Table1","ID=1"),"dd/mm/yy hh:mm:00")
    30/12/99 17:36:00
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #23
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,941
    Seems easier than writing formula
    22 posts and counting.

    I’m struggling to understand a production line that has a start time of 6:36 every day, with breaks at exactly the same time and length every day, never has a breakdown or stoppage for some reason. Unless it really never changes you need to recreate your lookup table all the time.

    but simply logging that detail in a table a formula along the lines I suggested would be simple to implement

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

Similar Threads

  1. Lookup values not appearing in Lookup field?
    By dominover in forum Access
    Replies: 4
    Last Post: 03-05-2016, 05:01 PM
  2. Replies: 4
    Last Post: 07-28-2015, 10:14 AM
  3. Replies: 3
    Last Post: 05-08-2015, 11:08 AM
  4. Replies: 5
    Last Post: 11-24-2014, 02:19 PM
  5. Replies: 5
    Last Post: 06-25-2014, 09:19 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