View Full Version : Help with Runtime Error 2465


Will123
02-16-2009, 08:48 AM
Hi, i've been having some trouble with runtime error 2465- "Microsoft access cant find the field "I" referred to in your expression"
I'm trying to select a record from a list box and then open a form with that records details filled out in the fields of the form. Both ISBN and Copy No are key fields if this makes a difference.
Heres the code:

Private Sub DeleteBook_Click()
Dim strDocName As String, strCriteria As String
Dim strCaption As String, strPupil As String

strDocName = "frmDeleteBooks"

strCriteria = ("ISBN='" & Me![LstBooks] & "'") And ([Copy No] = Me![LstBooks].Column(1))

DoCmd.OpenForm strDocName, , , strCriteria

End Sub

I can get it to open a form with the right ISBN but i have trouble getting it to take the Copy No into account aswell. ISBN is a string, Copy No is an integer.

Any help is appreciated.

pbaldy
02-16-2009, 08:54 AM
You started out right and then stopped concatenating your string. Try this:

strCriteria = ("ISBN='" & Me![LstBooks] & "') And ([Copy No] = " & Me![LstBooks].Column(1) & ")"

Will123
02-16-2009, 09:06 AM
Thats great! Thanks alot for the quick reply, it's working fine now. :D

pbaldy
02-16-2009, 09:08 AM
No problem, and welcome to the site by the way.

sailinxtc
04-01-2011, 06:55 PM
I am getting the same Runtime Error 2465 when utilizing the following code and the debug points to the If Statement. If I use the same code with a double click event the calculation works but don't utilize the If and Loop code, so not sure what I am missing with trying to use the on current event:

Private Sub Form_Current()
Call DisplayImage(Me.ImageFrame, Me!txtImageName & ".jpg")
Dim Hours As String
Dim Minutes As String

Do While IsEmpty([Age of Trail]) = True

If Not IsEmpty([Date Trail Laid]) And Not IsEmpty([Date Time Trail Laid]) And Not IsEmpty([Start Date of Trailing]) And Not IsEmpty([Start Time of Trailing]) Then

Hours = TimeDiff("h", [Start Time Trail Laid], [Start Time Trailing])
Dim Calculation As String
Minutes = TimeDiff("n", [Start Time Trail Laid], [Start Time Trailing])
Calculation = Minutes - (60 * Hours)
[Age of Trail] = DateDiff("d", [Date Trail Laid], [Start Date of Trailing]) & " days " & Hours & " hrs " & Calculation & " min"
DoCmd.RunCommand acCmdSaveRecord
Me.[Combo125] = Me![Age of Trail]
Exit_Calculate_Click:
Exit Sub

Else

End If

Loop


End Sub

Public Function TimeDiff(strInterval As String, _
dtStartTime As Date, _
dtStopTime As Date) As Long

TimeDiff = DateDiff(strInterval, #12:00:00 AM#, _
Format(TimeValue(dtStartTime) - 1 - TimeValue(dtStopTime), _
"hh:nn:ss"))

End Function

pbaldy
04-02-2011, 08:34 AM
I never use IsEmpty. More info here:

http://www.baldyweb.com/NullEmptyEtc.htm

Since those all look like date/time fields, I'd test with IsDate().

BIGPROFITT
02-29-2012, 06:51 AM
Option Compare Database
Option Explicit
Private GrpArrayPage() As Integer
Private GrpArrayPages() As Integer
Private GrpNameCurrent As String
Private GrpNamePrevious As String
Private GrpPage As Integer
Private GrpPages As Integer
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
Dim i As Integer
If Me.Pages = 0 Then
ReDim Preserve GrpArrayPage(Me.Page)
ReDim Preserve GrpArrayPages(Me.Page)
GrpNameCurrent = Me!Departed
If GrpNameCurrent = GrpNamePrevious Then
GrpArrayPage(Me.Page) = GrpArrayPage(Me.Page - 1) + 1
GrpPages = GrpArrayPage(Me.Page)
For i = Me.Page - ((GrpPages) - 1) To Me.Page
GrpArrayPages(i) = GrpPages
Next i
Else
GrpPage = 1
GrpArrayPage(Me.Page) = GrpPage
GrpArrayPages(Me.Page) = GrpPage
End If
Else
Me!ctlGrpPages = "Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page) & " in group"

End If
GrpNamePrevious = GrpNameCurrent
End Sub


Getting 2465 error in

Me!ctlGrpPages = "Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page) & "in group"

Please help.

Thanks