Unable to call Event from Module (1 Viewer)

leok31

Registered User.
Local time
Yesterday, 16:15
Joined
Feb 25, 2014
Messages
36
This is the code I'm trying to run from a Standard Module:
Code:
Public Sub RunPaxCalculations()
Dim frm As Form
Dim intNumberOfRecordsInFilter
Dim i As Integer
Set frm = Forms!vr_selection

'intNumberOfRecordsInFilter = frm.filter_entrance.ListCount

intNumberOfRecordsInFilter = 5 + 1
'Debug.Print intNumberOfRecordsInFilter


For i = 0 To intNumberOfRecordsInFilter
   ' Debug.Print i
    'Debug.Print frm.filter_entrance.Column(0, i)
    frm.filter_entrance.Value = frm.filter_entrance.Column(0, i)
    Forms("vr_selection").filter_entrance_Change
    i = i + 1
Next i

End Sub
When I run this I get Error2465,

But then I run the same code from a button on the form, and instead of
Forms("vr_selection").filter_entrance_Change
I use
call filter_entrance_Change

The code works. Can anyone see why this might be happening

Thank you.
 

ChrisO

Registered User.
Local time
Today, 09:15
Joined
Apr 30, 2003
Messages
3,202
Have you made the change event Public?

Chris.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 09:15
Joined
Jan 20, 2009
Messages
12,853
filter_entrance_Change would need to be a Public sub. They are Private by default.

BTW

I would suggest you pass the form object to the function. Otherwise the hard coded form in the function would mean there would be no point at all haiving it in a standard module.
 

leok31

Registered User.
Local time
Yesterday, 16:15
Joined
Feb 25, 2014
Messages
36
thanks for that.
I've changes the sub from private to public, but now I get this error:
The expression you entered as a query parameter produce this error:
'[txtbox_pream]'

txtbox_pream is a text box on the form whose value I pass as a parameter. But again, if I run the code from a button, I dont get these error.
Any ideas what could be causing it?
 

ChrisO

Registered User.
Local time
Today, 09:15
Joined
Apr 30, 2003
Messages
3,202
You're not giving us much to go on but are you using txtbox_pream or Forms("vr_selection").txtbox_pream?

Chris.
 

Users who are viewing this thread

Top Bottom