Results 1 to 8 of 8
  1. #1
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55

    Syntax error in control source of text box

    I am trying to use a Dlookup to find out the buying price of an item but am somehow getting my syntax wring due to my lack of experience...any help appreciated...I can get it to work before I multiply by the number of tickets so I think its something going wrong there.



    =DLookUp("[our buying price]","tbl_Price","[Type of Ticket]= '" & [TypeOfTicket] & "' And [SKU]= '" & [AttractionID] & "' * “ & “[nooftickets]”)

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    You have some strange quotes here
    * & [nooftickets]

    change each of these to "


    Is SKU a text or numeric?

  3. #3
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55
    Yes I'm sure I've done the quotes wrong somehow as I'm just copying examples from on line as don't understand syntax. Sku is text field thanks

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Did you make the changes, and did it work?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    As orange said, strange quote marks. Access doesn't like those funny slanted quote makes. Retype them.
    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.

  6. #6
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55
    Im afraid it still says invalid syntax - this is what it looks like now. Is it because nooftickets is numeric?

    =DLookUp("[our buying price]","tbl_Price","[Type of Ticket]= '" & [TypeOfTicket] & "' And [SKU]= '" & [AttractionID] & " * " [nooftickets]")

  7. #7
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,840
    your problem is here

    ....."' And [SKU]= '" & [AttractionID] & " * " [nooftickets]"

    Not clear what you are trying to achieve but at the minimum you need a closing single quote and you have a surplus double quote (in blue)

    if sku is constructed as something like

    1234 * 34

    then your code would be

    ....."' And [SKU]= '" & [AttractionID] & " * " & [nooftickets] & "'"

  8. #8
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55
    Thanks all, I was still getting #name for that code so I got rid of the multiplication and used the other dlook up and then made another text box and did the multiplication. All works fine now. Many thanks!

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

Similar Threads

  1. Text Box Control Source
    By ajs112 in forum Forms
    Replies: 1
    Last Post: 09-15-2014, 10:39 AM
  2. Replies: 13
    Last Post: 01-11-2012, 09:44 PM
  3. Replies: 5
    Last Post: 10-13-2011, 03:36 PM
  4. IIF statement in control source of text box
    By LilMissAttack in forum Reports
    Replies: 11
    Last Post: 08-18-2011, 10:02 PM
  5. Control Source for Text Box (#error)
    By km8415 in forum Forms
    Replies: 3
    Last Post: 06-27-2010, 10:45 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