Results 1 to 12 of 12
  1. #1
    Dalagrath is offline Only a Man
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Colorado
    Posts
    45

    Exclamation What's wrong with my code?

    Here is my code:



    Code:
    NPC1ACHit = DLookup([ArmorClass],"tblAttackMatrix",[Class] = Forms![frmBattleScreen]![NPC1subform]![ClassBOX] And [Level] = Forms![frmBattleScreen]![NPC1subform]![LevelBOX] And [TotalToHit] = Forms![frmBattleScreen]![ToHitRoll1Weap1])
    And my error is:



    Please help...

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    This should get you sorted out (the quotes aren't just for show)

    DLookup Usage Samples
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Dalagrath is offline Only a Man
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Colorado
    Posts
    45
    Ok, I changed it up, and now im getting a "Type Mismatch" error although all of these are numerical values.

    Code:
    NPC1ACHit = DLookup("[ArmorClass]", "tblAttackMatrix", "[Class] = " & Forms![frmBattleScreen]![NPC1subform]![ClassBOX] And "[Level] = " & Forms![frmBattleScreen]![NPC1subform]![LevelBOX] And "[TotalToHit] = " & Forms![frmBattleScreen]![ToHitRoll1Weap1])

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Your quotes are off. The only thing outside sets of quotes should be form references, and of course the &'s. Down near the bottom of that link is a multiple criteria example that may help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Dalagrath is offline Only a Man
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Colorado
    Posts
    45
    To be honest, your going to have to show me, because I have tried 3 different ways already and the same mismatch error.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Try

    DLookup("[ArmorClass]", "tblAttackMatrix", "[Class] = " & Forms![frmBattleScreen]![NPC1subform]![ClassBOX] & " And [Level] = " & Forms![frmBattleScreen]![NPC1subform]![LevelBOX] & " And [TotalToHit] = " & Forms![frmBattleScreen]![ToHitRoll1Weap1])
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Dalagrath is offline Only a Man
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Colorado
    Posts
    45
    Well, no more mismatch error, thank you. But it comes up as blank.

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    The syntax looks to be correct. So, this may sound like a silly question, but have you actually checked that there is a record that meets the required criteria?

  9. #9
    Dalagrath is offline Only a Man
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Colorado
    Posts
    45
    Lol, it's a fine question, kind of like "is it plugged in"?

    Yes, when I click the button, it looks at my Level (7), Class (War Priest, which both look at the ClassID), and The number my previous code randomizes.

    All three of these have a correlated number attached and should plop out a number.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Also, put in a breakpoint so you can make sure the values coming from the form references are what you expect. Can you post the db?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    Dalagrath is offline Only a Man
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Colorado
    Posts
    45
    Last edited by Dalagrath; 05-18-2011 at 12:03 PM. Reason: Duh

  12. #12
    Dalagrath is offline Only a Man
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Colorado
    Posts
    45
    Nevermind, I found out the issue.

    I forgot to Bracket the textbox or add a .Value

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

Similar Threads

  1. What is wrong with this IFF?
    By bburton in forum Reports
    Replies: 2
    Last Post: 03-16-2011, 10:42 AM
  2. Replies: 20
    Last Post: 09-18-2010, 02:31 PM
  3. What is wrong with this code?
    By nkenney in forum Forms
    Replies: 2
    Last Post: 11-16-2009, 03:04 PM
  4. Anything wrong with this one line of code?
    By alsoto in forum Reports
    Replies: 3
    Last Post: 07-01-2009, 09:23 AM
  5. What am I doing wrong?
    By brandon in forum Access
    Replies: 2
    Last Post: 08-03-2008, 10:26 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