Go Back   Access World Forums > Apps and Windows > Visual Basic

 
Reply
 
Thread Tools Rating: Thread Rating: 28 votes, 5.00 average. Display Modes
Old 02-16-2009, 09:48 AM   #1
Will123
Registered User
 
Join Date: Feb 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Will123 is on a distinguished road
Help with Runtime Error 2465

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.

Will123 is offline   Reply With Quote
Old 02-16-2009, 09:54 AM   #2
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,166
Thanks: 10
Thanked 3,887 Times in 3,830 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Help with Runtime Error 2465

You started out right and then stopped concatenating your string. Try this:

strCriteria = ("ISBN='" & Me![LstBooks] & "') And ([Copy No] = " & Me![LstBooks].Column(1) & ")"
__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 02-16-2009, 10:06 AM   #3
Will123
Registered User
 
Join Date: Feb 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Will123 is on a distinguished road
Talking Re: Help with Runtime Error 2465

Thats great! Thanks alot for the quick reply, it's working fine now.

Will123 is offline   Reply With Quote
Old 02-16-2009, 10:08 AM   #4
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,166
Thanks: 10
Thanked 3,887 Times in 3,830 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Help with Runtime Error 2465

No problem, and welcome to the site by the way.
__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 04-01-2011, 06:55 PM   #5
sailinxtc
Newly Registered User
 
Join Date: Apr 2008
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
sailinxtc is on a distinguished road
Re: Help with Runtime Error 2465

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
sailinxtc is offline   Reply With Quote
Old 04-02-2011, 08:34 AM   #6
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,166
Thanks: 10
Thanked 3,887 Times in 3,830 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Help with Runtime Error 2465

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().
__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 02-29-2012, 07:51 AM   #7
BIGPROFITT
Newly Registered User
 
Join Date: Jun 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
BIGPROFITT is on a distinguished road
Re: Help with Runtime Error 2465

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

BIGPROFITT is offline   Reply With Quote
Old 06-29-2012, 06:06 AM   #8
jmolvr
Newly Registered User
 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jmolvr is on a distinguished road
Re: Help with Runtime Error 2465

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
jmolvr is offline   Reply With Quote
Old 06-29-2012, 07:02 AM   #9
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,166
Thanks: 10
Thanked 3,887 Times in 3,830 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Help with Runtime Error 2465

Does this work?

Application.FollowHyperlink Me.[ObitFile]
__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 01-15-2013, 04:33 PM   #10
KiEESH
Newly Registered User
 
Join Date: Jan 2013
Posts: 32
Thanks: 2
Thanked 0 Times in 0 Posts
KiEESH is on a distinguished road
Re: Help with Runtime Error 2465

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!!
KiEESH is offline   Reply With Quote
Old 01-15-2013, 05:10 PM   #11
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,166
Thanks: 10
Thanked 3,887 Times in 3,830 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Help with Runtime Error 2465

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.
__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 01-15-2013, 05:16 PM   #12
KiEESH
Newly Registered User
 
Join Date: Jan 2013
Posts: 32
Thanks: 2
Thanked 0 Times in 0 Posts
KiEESH is on a distinguished road
Re: Help with Runtime Error 2465

that's IT!
thanks a million!
KiEESH is offline   Reply With Quote
Old 01-15-2013, 06:00 PM   #13
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,166
Thanks: 10
Thanked 3,887 Times in 3,830 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Help with Runtime Error 2465

No problemo!
__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 03-14-2018, 12:06 AM   #14
KonstantinSH
Newly Registered User
 
Join Date: Mar 2018
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
KonstantinSH is on a distinguished road
Smile Re: Help with Runtime Error 2465

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 by KonstantinSH; 03-14-2018 at 12:48 AM.
KonstantinSH is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2007 runtime opens and closes immediately paulohm1 General 8 02-08-2014 08:09 AM
Access Runtime configuration Phonik General 6 11-08-2006 06:26 AM
Two questions about Access Runtime keiths General 0 11-14-2005 02:11 PM
Creating Runtime Deployment b19620719 General 1 11-03-2005 05:45 AM
Access Runtime - Runtime error mazza Modules & VBA 3 07-13-2005 12:19 PM




All times are GMT -8. The time now is 09:13 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World