Results 1 to 6 of 6
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195

    Report Field Control Source

    Hi Guy's, On a report i have a text box not bound to a field but looking up a mobile number form contacts table



    If there is no mobile number added, i get #error

    Text Box Control Source:
    Code:
    =DLookUp("Mobile","tblDealers","[PostCode] = txtPostCode And [Name] = txtDelTo")
    How do i not add anything if a mobile number doesn't exist ?

    do i use Iif or Nz

    if so, how do i write it in ?

    much appreciated

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Think your dlookup is wrong. These are text values so would think it would need to be

    =DLookUp("Mobile","tblDealers","[PostCode] = '" & txtPostCode & "'And [Name] = '" & txtDelTo & "'")

    which should return a zls if nothing found

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Ahh thank s CJ London, so just need to add string delimiters in there even though the criteria's are text boxes with no control source ?

    KR

    Dave

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    The textboxes have values though?, that is why you are using them?
    If it was just the same values all the time, only then could you hardcode it as you have done. Even then you would use the actual values and not the controls.
    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. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    just to add to WGM's comments, you would still need the text delimiters even if the values were hard coded because the fields you are applying the criteria to are text

    =DLookUp("Mobile","tblDealers","[PostCode] = 'ab12 3wq' And [Name] = 'george'")

  6. #6
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi Guys thank you, yes just needed the text delimiters in, unsure why i didn't think of that one!!

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

Similar Threads

  1. Replies: 2
    Last Post: 05-28-2015, 12:12 PM
  2. #Name error on Report's Control Source
    By gaker10 in forum Reports
    Replies: 1
    Last Post: 11-14-2014, 10:43 AM
  3. Replies: 3
    Last Post: 05-03-2014, 03:26 AM
  4. Report Control Source Manipulation
    By justphilip2003 in forum Reports
    Replies: 15
    Last Post: 05-19-2013, 10:06 PM
  5. Two passes through report's control source?
    By GraeagleBill in forum Reports
    Replies: 2
    Last Post: 09-03-2012, 05:50 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