Runtime error '2465'

boblife42

Registered User.
Local time
Yesterday, 22:23
Joined
May 30, 2008
Messages
32
Hello all
I am getting the following runtime error 2465 - Application-defined or Object-defined error when I run the following code.
Code:
Private Sub sfrm_Image_Count_Enter()
Dim rs As Recordset
Dim strSQL As String

strSQL = "SELECT * FROM tbl_Monthly_Estimate WHERE [ProjectID] = '" & Forms!frm_projectdata.ProjectKey & "' "
Set rs = CurrentDb.OpenRecordset(mySQL)

If rs!TableInformation = "tbl_TechTime" Then
Me.sfrm_Image_Count.LinkChildFields = "ProjectID"
Me.sfrm_Image_Count.LinkMasterFields = "ProjectKey"
Else
Me.sfrm_Image_Count.LinkChildFields = "ProjectID, Status"
Me.sfrm_Image_Count.LinkMasterFields = "ProjectKey, ServiceName"
End If

End Sub

What I want to do is change the link between the subform and form based on a field in the subform. If it is tbl_TechTime then I just want to link by the ProjectID to ProjectKey. If the field is tbl_History then I want to link by ProjectID to ProjectKey AND Status to ServiceName.

Thank you for any help you can give.
 
2 things jump out at me first off.

1. Declare your recordset as DIM rs As DAO.Recordset

2. You need to change this line:
Set rs = CurrentDb.OpenRecordset(mySQL)

to this
Set rs = CurrentDb.OpenRecordset(strSQL)
 
In addition to Bob's excellent advice, you can get more information by doing this whenever you see a generic "Application or Object-defined Error"-

In the immediate windows of VBE, type:

Code:
?AccessError(2465)

Which will give you more detail about the error and help you with the debugging.
 
In addition to Bob's excellent advice, you can get more information by doing this whenever you see a generic "Application or Object-defined Error"-

In the immediate windows of VBE, type:

Code:
?AccessError(2465)

Which will give you more detail about the error and help you with the debugging.

Good stuff and one more thing I didn't know that I will be adding to my "bag-o-tricks" :D
 
Hello, I need some help

I received the same above error in this code when I did a compilation. It stops at the second subformFees under the Else. It is indicating that it cannot recognize this field name. It is not a field. It is the name of the form. :(

Private Sub Toggle_View_Click()
If Me![Toggle View].Caption = " &View Fee Schedule" Then
Me![subformEvents].Visible = False
Me![subformFees].Caption = "&View Attendanees"

Else
Me![subformFees].Visible = False
Me![subformEvents].Visible = True
Me![Toggle View].Caption = "&View Fee Schedule"
End If
End Sub
 
sometimes vba seems to object to the use of currentdb

i find throwing in the extra

dim dbs as database
set dbs=currentdb

set rst=dbs.openrecordset etc

avoids these "scope type errors"
 

Users who are viewing this thread

Back
Top Bottom