Page 2 of 2 FirstFirst 12
Results 16 to 28 of 28
  1. #16
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    I'm closing this thread because an acceptable solution is found in support of the app. However, the solution to the OP is not really satisfied in that there's no reason found as to why the Boolean return from the functions does not work.

  2. #17
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Did you verify that there were no Null or invalid dates?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #18
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Easy enough to filter out Null dates I would have thought?, or use the NZ() function?
    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

  4. #19
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Sure, but I didn't see the issue being raised.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #20
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    It is puzzling that the code of the function works directly in the query?
    I would be trying the NZ() or looking for bad data.
    The data set could have changed since it worked directly in the query?
    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

  6. #21
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Quote Originally Posted by pbaldy View Post
    Sure, but I didn't see the issue being raised.
    Surely someone edited their post then, because I started to suggest that but before posting I went back and reviewed. I seem to recall that based on that review I deleted my post because it had been addressed. Here's what I saw when I hit the restore button:
    Click image for larger version. 

Name:	1restore.jpg 
Views:	20 
Size:	24.2 KB 
ID:	50874
    Click image for larger version. 

Name:	2restore.jpg 
Views:	20 
Size:	17.5 KB 
ID:	50875
    I also could not get an error in the immediate window by comparing ?Left("",5) = Left("",5) (was True) so it didn't seem reasonable that it would raise that error as a returned function value. That it works as a calculated field but not as a function call suggests to me that as a call, it must be returning something the function can't handle, and that certainly could be nulls:
    ?left(null,5) = left(null,5)
    Null
    and a boolean cannot be null. I'd use something other than Boolean.

    Now I think I should have made that post.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #22
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by Micron View Post
    Surely someone edited their post then
    That's possible. I searched for "Null" in the thread and didn't see it prior to posting.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #23
    Edgar is online now Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    First reply in this thread is me saying the data is wrong if the function is right. OP seems to have not done any data validation test so far, so, my suggestion remains: check the underlying data. If it's too much data, then check it out by chunks until any chunk throws an error and then keep isolating and reducing until the record(s) with invalid data is found.
    Please click on the ⭐ below if this post helped you.


  9. #24
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    A lot of re-tracing here trying to answer WHY the "Birthday" function failed. So, here's what happened. I have several apps, two of which are of a similar nature, quite old I might add. One of the apps has a feature that had been requested to be included in the second. Some code from a general module got copied from the 1st app to the 2nd app. The 1st app had a Public Function "Birthday", but the 2nd app, unbeknown to me, also had a Public Function "Birthday". The difference was that the functions, though similar, performed different functions and where one returned Boolean, the other returned String. It all went down-hill from there. The worst part of it all is the amount of time I wasted on all those that followed the thread. I am terribly sorry.

  10. #25
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    I thought a compile highlighted that fact?
    I am sure I have copied some code over and then found I l aready had it in another module?
    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

  11. #26
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I thought a compile highlighted that fact?
    Yes, normally one would rely on that, but those of us that have unique ways of screwing things up know how to avoid that.

  12. #27
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Compile?!? We don't need no stinking compile!!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #28
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Are you saying that
    a) you never ran a compile when this started (assuming you didn't copy the code over)
    b) you never put a break point on the code with the intention of examining the data type of the function's return value? This would have been a dead give away because your never would have encountered the boolean function break point if instead the string function ran. Troubleshooting 101, day 1.

    I for one am amazed that you didn't get "Ambiguous name detected" error regardless. Unless you called the wrong function name (not realizing there is a slight difference) but posted code from the correct one I can't see how that error didn't arise at run time. I think I'd be importing everything into a new db if that is the case. I could be wrong, but I can't see how Access didn't raise that error at run time, even without a compile.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Data Type Mismatch when Trying to Sum a Qry
    By Tuckejam in forum Queries
    Replies: 6
    Last Post: 07-07-2020, 10:58 AM
  2. Data Type MisMatch
    By Eranka in forum Access
    Replies: 4
    Last Post: 10-31-2019, 03:58 AM
  3. Data Type MisMatch
    By Eranka in forum Access
    Replies: 2
    Last Post: 10-23-2019, 04:43 AM
  4. data type mismatch
    By ottoc in forum Queries
    Replies: 1
    Last Post: 12-02-2014, 09:42 AM
  5. Data Type Mismatch
    By timmy in forum Programming
    Replies: 9
    Last Post: 04-12-2011, 03:48 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