Results 1 to 5 of 5
  1. #1
    uncletreetrunk is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2012
    Posts
    72

    DLookup Syntax Error

    Hi all,

    I don't what's giving me error 3075. Syntax Error

    Code:
    Public Function IsInTable(tblName As String) As Boolean
    If Me.ProgNum.Value = DLookup("Program Number", tblName, "[Program Number] = " & Forms!Add!ProgNum) Then
    And I call IsInTable
    Code:
    If IsInTable("Historical") = False Then 
    Exit Sub
    I followed this link that pbaldy provided to me earlier
    http://access.mvps.org/access/general/gen0018.htm



    I'm sure it's simple but I can't seem to find it....

    Thanks for your help!

  2. #2
    uncletreetrunk is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2012
    Posts
    72
    Oh and Program Number is a general number field in the table, I've double checked

  3. #3
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Your Dlookup needs to look like this:

    DLookup("[Program Number]", tblName, "[Program Number] = " & Forms!Add!ProgNum)

    with the first "Program Number" in square brackets as well, even though it is in quotes.

    If any of your table names contain spaces, they will cause trouble as well, so you could use the DLookup like this:

    DLookup("[Program Number]", "[" & tblName & "]", "[Program Number] = " & Forms!Add!ProgNum)

    HTH

    John
    Last edited by John_G; 07-30-2012 at 02:11 PM. Reason: additional comment

  4. #4
    uncletreetrunk is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2012
    Posts
    72
    Thanks for you help John! I know the spaces aren't according to naming convention, but I learned after I had setup most of this database :P

  5. #5
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Glad I could help.

    I tend to use spaces myself (and, yes, I know they're frowned on!); I just have to remember to use the square brackets all the time.

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

Similar Threads

  1. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  2. IIf and dlookup syntax
    By AndycompanyZ in forum Forms
    Replies: 3
    Last Post: 06-28-2011, 02:47 PM
  3. DLookup() syntax????
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 03-30-2011, 09:14 AM
  4. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  5. dlookup() syntax
    By markjkubicki in forum Programming
    Replies: 4
    Last Post: 08-24-2010, 12:31 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