Help with Runtime Error 2465 (1 Viewer)

Will123

New member
Local time
Today, 16:41
Joined
Feb 16, 2009
Messages
5
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

Wino Moderator
Staff member
Local time
Today, 16:41
Joined
Aug 30, 2003
Messages
36,118
You started out right and then stopped concatenating your string. Try this:

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

Will123

New member
Local time
Today, 16:41
Joined
Feb 16, 2009
Messages
5
Thats great! Thanks alot for the quick reply, it's working fine now. :D
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 16:41
Joined
Aug 30, 2003
Messages
36,118
No problem, and welcome to the site by the way.
 

sailinxtc

Registered User.
Local time
Today, 18:41
Joined
Apr 27, 2008
Messages
34
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
 

BIGPROFITT

New member
Local time
Today, 19:41
Joined
Jun 24, 2008
Messages
2
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
 

jmolvr

New member
Local time
Today, 19:41
Joined
Jun 29, 2012
Messages
1
I have a similar question with the runtime error 2465. I am trying to get VB to display a jpg file on click. I have the jpgs in a directory on my computer. But when I click on the entry I get a runtime error with Microsoft Office cannot find the field '|' referred to in your expression. The code I am using is short, I just want to display the file on a click.


Private Sub Obitjpg_Click()
Application.FollowHyperlink "" & Me.[ObitFile]
End Sub


Any suggestions? Thank you. jmolvr
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 16:41
Joined
Aug 30, 2003
Messages
36,118
Does this work?

Application.FollowHyperlink Me.[ObitFile]
 

KiEESH

Registered User.
Local time
Today, 19:41
Joined
Jan 16, 2013
Messages
32
Hi-

I have a form/subform relationship that should allow users to enter search options on the main form, click a search button on that same form, then view & edit the results in the subform.

I've tried every iteration of "Me!, Me., Me!MainFormName!SubFormName.Form. (and !) RecordSource" references and my spelling is correct. Still no luck. My subform continues to not be recognized.

Here's my code and the highlighted bug:

Option Compare Database
Option Explicit
Private Sub btnClear_Click()
Dim intIndex As Integer

' Clear all search items
Me!cmbZONE = ""
Me!txtBLDG_NUM = ""
Me!cmbCOMPASS_PT = ""
Me!txtSTREET = ""
Me!cmbATERY = ""


End Sub
Private Sub Form_Load()

' Clear the search form
btnClear_Click

End Sub
Private Sub btnSearch_Click()

' Update the record source
Me!frmsub_EditBldg.Form.RecordSource = "Select * From qry_AREA_GROWTH2" & BuildFilter

' Requery the subform
'Me!frmsub_EditBldg.Form.Requery


End Sub
Private Function BuildFilter() As Variant
Dim varWhere As Variant
Dim varItem As Variant
Dim intIndex As Integer
varWhere = Null ' Main filter

' Check for ZONE
If Me!cmbZONE > "" Then
varWhere = varWhere & "[ZONE] = " & Me.cmbZONE & " AND "
End If

' Check for LIKE BLDG_NUM
If Me!txtBLDG_NUM > "" Then
varWhere = varWhere & "[BLDG_NUM] LIKE """ & Me.txtBLDG_NUM & "*"" AND "
End If

' Check for COMPASS_PT
If Me!cmbCOMPASS_PT > "" Then
varWhere = varWhere & "[COMPASS_PT] = " & Me.cmbCOMPASS_PT & " AND "
End If

' Check for LIKE STREET
If Me!txtSTREET > "" Then
varWhere = varWhere & "[STREET] LIKE """ & Me.txtSTREET & "*"" AND "
End If

' Check for ATERY
If Me!cmbATERY > "" Then
varWhere = varWhere & "[ATERY] = " & Me.cmbATERY & " AND "
End If


' Check if there is a filter to return...
If IsNull(varWhere) Then
varWhere = ""
Else
varWhere = "WHERE " & varWhere

' strip off last "AND" in the filter
If Right(varWhere, 5) = " AND " Then
varWhere = Left(varWhere, Len(varWhere) - 5)
End If
End If

BuildFilter = varWhere

End Function




I believe the section in question (above) refers to a query. However, I prefer that my subform's record source be a table that can edited. I tried creating a query and making that the subform's record source, but I still received the error, so I don't believe that the lack of query is the real issue here.

This seemed so simple in the code I found online.
Yet, it doesn't work for me.


Please help!! :banghead:
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 16:41
Joined
Aug 30, 2003
Messages
36,118
If the name of the subform itself and the name of the subform control on the main form are different, you need the name of the control in that code.
 

KonstantinSH

New member
Local time
Today, 16:41
Joined
Mar 14, 2018
Messages
1
Help with code, please. It must take a information from Query, transform it in words "Отправлен" or "Еще на станции" and put data in table, but I have a error 2465. How to fix it?


Private Sub Кнопка_маршрутов_Click()
Dim Znachenie As String
'Открыть все необходимые формы и таблицы, чтобы не было проблем с проверкой If
DoCmd.OpenForm ("Новый_маршрут")
DoCmd.OpenTable ("Расписание автостанции")
DoCmd.OpenForm ("Форма навигации")
DoCmd.OpenQuery ("Статус_отправления")
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If DLookup("С", "Статус_отправления", "С=1") Then
Znachenie = "Еще на станции" & [Forms]![Новый_маршрут]![Статус] = [Znachenie] & [Tibles]![Расписание автостанции]![Статус] = [Znachenie] & Me.[Forms]![Новый_маршрут]![Статус].Value & "'"
Else
Znachenie = "Отправлен" & DLookup("Статус", "Расписание автостанции", "Статус" = (Znachenie)) & Me.[Forms]![Новый_маршрут]![Статус].Value & "'"
'Znachenie = "Еще на станции" & [Forms]![Новый_маршрут]![Статус] = [Znachenie] & [Tibles]![Расписание автостанции]![Статус] = [Znachenie] & Me.[Forms]![Новый_маршрут]![Статус].Value & "'"

End If
'---------- Закрыть все после проверки данных -------------------------------------
DoCmd.Close , "Расписание автостанции"
DoCmd.Close , "Статус_отправления"
DoCmd.Close , "Форма навигации"
End Sub

P.S. Query was create by function IIF and timer function. С: IIf([Расписание автостанции]![Время отправки]>=[Forms]![Форма навигации]![Timetb];1;2)

Thank you for any help.
 
Last edited:

Users who are viewing this thread

Top Bottom