Results 1 to 3 of 3
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question SQL inside DLookup()

    Forgive me but I thought this would be something simple. I am trying to execute a piece of SQL inside a DLookup(). Is that possible? I keep getting a run-time error when I try to execute.



    Code:
            mySQL = "SELECT * FROM tblSKUMin_Max WHERE [SKU] = '" & vSKU & "';"
            vMin = DLookup("SKUMin", mySQL, "[SKUClass] = '" & vStoreClass & "'")
            vMax = DLookup("SKUMax", mySQL, "[SKUClass] = '" & vStoreClass & "'")
            Form_SfrmEmail.txtMedMin.Value = vMin
            Form_SfrmEmail.txtMedMax.Value = vMax
    Error States:
    "The Microsoft Acces database engine cannot find the input table or query 'SELECT * FROM tblSKUMin_Max WHERE [SKU] = '(SKU NUMBER)';'. Make sure it exists and that its name is spelled correctly."

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    the second argument is a table or query name, sir. you can't do what you're doing.

    to be sure though, look the function up in VBA help and read the description of the arguments. if sql statements are accepted, it will say so. I'm 99 sure though, that it won't say that.

    makes sense too, actually....that would require the engine to do two tasks at once that are complicated. that's prrobably the rationale...

  3. #3
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Understood. Thank you.

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

Similar Threads

  1. Iif inside a update satement.
    By meet_binay in forum Queries
    Replies: 0
    Last Post: 02-18-2011, 04:18 AM
  2. select statement inside values?
    By hung_ko in forum Access
    Replies: 4
    Last Post: 01-01-2011, 10:06 PM
  3. How to put a prompt message inside a text box
    By usmcgrunt in forum Forms
    Replies: 3
    Last Post: 11-05-2010, 09:55 AM
  4. Rounded number inside of text
    By Lockrin in forum Access
    Replies: 6
    Last Post: 01-27-2010, 12:26 PM
  5. Can access have a table view inside a form
    By mossman in forum Access
    Replies: 5
    Last Post: 01-17-2010, 12:19 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