Results 1 to 2 of 2
  1. #1
    zachlunch is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    7

    [CopyPaste Programmer] Variable not found

    I have been asked to build on top of one of the premade databases on Access 2010, the student database. I have been making new forms to mirror already created ones with simple copy paste techniques and changing variables here and there. Now, I messed up the student list form, one of the premade forms, so I can't fix it and am barred from creating new lists based of the premade student list. I don't know much about Access besides what I have done trying to emulate this template. This is the section of code that I believe is the problem, since it stops compiling. The problem is on line 15:


    Code:
    SearchBox.Text = ""
    Code:
    '------------------------------------------------------------
    ' SearchGo_Click
    '
    '------------------------------------------------------------
    Private Sub SearchGo_Click()
    On Error GoTo SearchGo_Click_Err
        If (Eval("[Form]![SearchBox] Is Null Or [Form]![SearchBox]=""""")) Then
            ' Clear Filter when search box empty
            DoCmd.ApplyFilter "", """""", ""
            DoCmd.GoToControl "SearchBox"
            DoCmd.SetProperty "SearchClear", acPropertyVisible, "0"
            DoCmd.SetProperty "SearchGo", acPropertyVisible, "-1"
        End If
        If (Eval("[CurrentProject].[IsTrusted] And ([Form]![SearchBox] Is Null Or [Form]![SearchBox]="""")")) Then
            SearchBox.Text = ""
        End If
        If (Eval("[Form]![SearchBox] Is Null Or [Form]![SearchBox]=""""")) Then
            End
        End If
        If (VarType(Form!SearchBox) <> 8) Then
            End
            DoCmd.SetProperty "SearchGo", acPropertyVisible, "-1"
        End If
        If (Eval("([Form]![SearchBox] Is Null Or [Form]![SearchBox]="""") And [SearchClear].[Visible]<>0")) Then
            DoCmd.SetProperty "SearchClear", acPropertyVisible, "0"
            End
        End If
        ' Handle "'s in search
        TempVars.Add "strSearch", Replace(Form!SearchBox, """", """""")
        ' Build the Filter
        TempVars.Add "strFilter", "([Last Name] Like "" * " & [TempVars]![strSearch] & " * "" )"
        TempVars.Add "strFilter", TempVars!strFilter & " OR ([First Name] Like "" * " & [TempVars]![strSearch] & " * "" )"
        If (Form.Name = "Guardian List") Then
            TempVars.Add "strFilter", TempVars!strFilter & " OR ([Company] Like "" * " & [TempVars]![strSearch] & " * "" )"
        End If
        If (Form.Name = "Guardian List") Then
            TempVars.Add "strFilter", TempVars!strFilter & " OR ([Job Title] Like "" * " & [TempVars]![strSearch] & " * "" )"
        End If
        TempVars.Add "strFilter", TempVars!strFilter & " OR ([E-mail Address] Like "" * " & [TempVars]![strSearch] & " * "" )"
        If (Form.Name = "Student List") Then
            TempVars.Add "strFilter", TempVars!strFilter & " OR ([Student ID] Like "" * " & [TempVars]![strSearch] & " * "" )"
        End If
        If (Form.Name = "Student List") Then
            TempVars.Add "strFilter", TempVars!strFilter & " OR ([ID Number] Like "" * " & [TempVars]![strSearch] & " * "" )"
        End If
        TempVars.Add "strFilter", TempVars!strFilter & " OR ([Web Page] Like "" * " & [TempVars]![strSearch] & " * "" )"
        TempVars.Add "strFilter", TempVars!strFilter & " OR ([Notes] Like "" * " & [TempVars]![strSearch] & " * "" )"
        DoCmd.ApplyFilter "", TempVars!strFilter, ""
        TempVars.Remove "strFilter"
        TempVars.Remove "strSearch"
        DoCmd.SetProperty "SearchClear", acPropertyVisible, "-1"
        DoCmd.GoToControl "SearchBox"
        DoCmd.SetProperty "SearchGo", acPropertyVisible, "-1"
    
    SearchGo_Click_Exit:
        Exit Sub
    SearchGo_Click_Err:
        MsgBox Error$
        Resume SearchGo_Click_Exit
    End Sub
    Thanks for looking at my thread any help would be appreciated. I tried opening a new student database and copying all the code to "reset" everything, but I still get issues with the form when trying to use the search box inside the student list. I'm sure this sounds vague, and hard to help with, but I'll try to reply and clarify anything if need be. Thank you.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    I've never used Eval function in If conditional code. Never used DoCmd.GoToControl either (I have used SetFocus). I have never seen End used solo.

    Don't use .Text property. You need to set the Value property. Value is default if no property is specified.

    You might want to delete the bad pre-built form and import it from the original template.
    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.

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

Similar Threads

  1. Access Programmer
    By Kristi.owen091010 in forum Access
    Replies: 1
    Last Post: 04-01-2012, 08:45 PM
  2. Access 97 programmer needs a refresh
    By rlam in forum Programming
    Replies: 1
    Last Post: 02-02-2012, 12:18 AM
  3. Programmer Wanted
    By Hoota Caroota in forum Access
    Replies: 2
    Last Post: 11-15-2010, 08:56 PM
  4. Replies: 10
    Last Post: 11-09-2010, 03:34 PM
  5. DB2, MySQL Programmer needs Access Answer
    By cgaccess in forum Access
    Replies: 1
    Last Post: 09-23-2010, 09:18 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