Results 1 to 2 of 2
  1. #1
    Sohail Anjum is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    1

    Run-time error '2465': MS Access can't find the field '|' referred to in your expres

    I got problem when i was finding grade of student the code is below:

    Private Sub gradeObtained_GotFocus()
    If ([marksPercentage] >= 80 & [marksPercentage] < 100) Then
    [marksPercentage] = "A+"
    End If
    If ([marksPercentage] >= 70 & [marksPercentage] < 80) Then
    [marksPercentage] = "A"
    End If
    If ([marksPercentage] >= 60 & [marksPercentage] < 70) Then
    [marksPercentage] = "B"
    End If
    If ([marksPercentage] >= 50 & [marksPercentage] < 60) Then
    [marksPercentage] = "C"
    End If
    If ([marksPercentage] >= 40 & [marksPercentage] < 40) Then
    [marksPercentage] = "D"
    End If


    End Sub

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Your statements should be using AND not &. & is a concatenation character.

    Agreed we often use & in writing to shorten AND, but syntactically here you need the Literal AND

    If ([marksPercentage] >= 80 & [marksPercentage] < 100) Then

    should be If ([marksPercentage] >= 80 AND [marksPercentage] < 100) Then

    True for all of your AND conditions.

    This construct does not make sense -can't be >=40 AND <40 ??????
    If ([marksPercentage] >= 40 & [marksPercentage] < 40) Then
    [marksPercentage] = "D"

    You may have missed a >= 40 and <50
    but you still need something for <40

    You could use a Select Case construct for this sort of thing also.
    Last edited by orange; 12-01-2012 at 08:20 PM. Reason: missed an =

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

Similar Threads

  1. Replies: 5
    Last Post: 05-04-2019, 09:02 PM
  2. Replies: 5
    Last Post: 06-09-2012, 12:37 PM
  3. Run Time Error 2465
    By jo8701 in forum Programming
    Replies: 1
    Last Post: 02-08-2012, 12:01 PM
  4. Run-Time error '2465'
    By hawkins in forum Access
    Replies: 6
    Last Post: 08-19-2011, 04:07 PM
  5. Replies: 1
    Last Post: 07-21-2009, 03:01 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