Results 1 to 4 of 4

Thread: [RESOLVED] Access VBA: "Run-time Error 2001"

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    48

    [RESOLVED] Access VBA: "Run-time Error 2001"

    Im getting an error with this bit of code:

    VB Code:
    1. Dim sForename As String
    2.         Dim sSurname As String
    3.         Dim sCode As String
    4.        
    5.         sCode = DLookup("staffCode", "booking", "bookingDate = #" & dDate & _
    6. "# AND timeID = " & timeID & " AND areaID = " & areaID)
    7.                
    8.         sForename = DLookup("[staffForeName]", "staff", "[staffCode] = " & sCode)
    9.        
    10.         sSurname = DLookup("staffSurName", "staff", "staffCode = " & sCode)
    11.                
    12.         MsgBox "The booking has already been booked by " & sForename & " " & sSurname

    Its screwing up on the "sForename = DLookup" line.... and the "sSurname = Dlookup" line

    Any help would be appriciated!!
    Last edited by c03cg; Jul 18th, 2006 at 09:23 AM.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Access VBA: "Run-time Error 2001"

    is staffcode a string?

    VB Code:
    1. sForename = DLookup("[staffForeName]", "staff", "[staffCode] = '" & sCode & "'")
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    48

    Re: Access VBA: "Run-time Error 2001"

    How dim do i feel! Yes its a string and i read they needed to be in quotes..... just forgot to add it in!!

    Thanks Fella

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: [RESOLVED] Access VBA: "Run-time Error 2001"

    Fella? lol

    no problem
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width