Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922

    Len simply returns a number. It sounds like you are still having problems with this code.

  2. #17
    KathyL is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    94
    Quote Originally Posted by OldCityCat View Post
    I just trying to do a simple lookup in my UsedbookingNumber table to check if a numbers has been used.
    This code is runs after LostFocus of the BookingNoticeBookingNo field.

    Code:
    DLookup("[UsedBookingNum]", "UsedBookingNumber", "[UsedBookingNum] = _
    " & Forms![frmAsiaBooking]![BookingNoticeBookingNo])
    I have tried many variations and get errors like:
    "Type Mismatch" ,
    "The expression you entered as a query parameter produced this error: WLK533741"
    Which happens to be first number in my used number table.
    and Runtime error 3075. Syntax error (missing operator) "[UsedBookingNum] = "
    I have verified all fields are data type "Text"


    Thank you in advance for any and all suggestions

    OldCityCat
    Do you have the lookup field defined with an index or key?

    Are you doing this lookup as a calculated field on a form, or in event VB code? In a form's calculated field/text box, be sure you have included the '=' in front of the Dlookup.

    I've been tripped up with the very error you're getting, 'cause I forgot the '=', or not having the field defined with an index.

  3. #18
    OldCityCat is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    33
    KathyL,

    Do you have the lookup field defined with an index or key? "Yes indexed allow dups"

    Are you doing this lookup as a calculated field on a form, No

    or in event VB code? In a form's, "This code is runs after LostFocus"

    calculated field/text box, be sure you have included the '=' in front of the Dlookup. " It's If DLookup"

    I've been tripped up with the very error you're getting, 'cause I forgot the '=', or not having the field defined with an index.

    Thanks
    OldCityCat

  4. #19
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you using the code I posted in Post #8? You're still having trouble? Copy and Paste the code you are using into a post, please.

  5. #20
    OldCityCat is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    33
    Sorry I forgot to say it was working
    Now I'm just trying to understand how/why

    When adding a new record, and using a booking number that I know is in the UsedBookingNumber table.
    DLookup should have found a match ,but still returned an Type mismatch error?

    Where does Null come into play?

    So LEN looks for any string grater then 0?

    Don't mean to be a pain, just want to learn.

    OldCityCat

  6. #21
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you looked up DLookup() and Len() in help to see how they work?

  7. #22
    OldCityCat is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    33
    Yes,
    I what to understand the difference between your code and my original code.

  8. #23
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    One of the biggest issues was you were treating the [UsedBookingNum] field as a number when it was a string.

  9. #24
    KathyL is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    94
    Quote Originally Posted by OldCityCat View Post

    or in event VB code? In a form's, "This code is runs after LostFocus"

    calculated field/text box, be sure you have included the '=' in front of the Dlookup. " It's If DLookup"

    I've been tripped up with the very error you're getting, 'cause I forgot the '=',
    you still have to have an '=' in VB code, I think. On either a DLookup or IIF

    http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx

    http://office.microsoft.com/en-us/ac...001228853.aspx

    DLookup itself is not VB code, it is a Function. And you have to equate the function to something.

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

Similar Threads

  1. Replies: 3
    Last Post: 04-10-2010, 10:22 AM
  2. Replies: 21
    Last Post: 06-03-2009, 05:54 PM
  3. aSTR = Dir("C:\*.*") >> "Type Mismatch"
    By JGrant in forum Programming
    Replies: 1
    Last Post: 03-28-2009, 05:17 AM
  4. Replies: 2
    Last Post: 08-31-2006, 12:19 PM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 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