Not in List on subform (1 Viewer)

andy1968

Registered User.
Local time
Today, 04:33
Joined
May 9, 2018
Messages
131
Having trouble with this issue. I'm using code borrowed from somewhere else. I want the code to be independent of the from I am originating the event from.



The original code was driven by an event on a main form. My issue is how to get the code to recognize the name of the subform.


I get an error from the frm variable. It stores the name of the main form.



Code:
Private Sub Title_NotInList(NewData As String, Response As Integer)

Dim frm As String
Dim ctl As String

frm = Screen.ActiveForm.Name

ctl = Screen.ActiveControl.Name
Response = EnterNewTitle(NewData, frm, ctl)


End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:33
Joined
Oct 29, 2018
Messages
21,496
Hi. One way for the function to "know" the name of the subform is to "pass" it to the function.
 

andy1968

Registered User.
Local time
Today, 04:33
Joined
May 9, 2018
Messages
131
I'd like it to be able to run from any form - or subform.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:33
Joined
Oct 29, 2018
Messages
21,496
I'd like it to be able to run from any form - or subform.
Hi. Wherever you "run" some code, there must be some sort of awareness going on. If so, then it shouldn't be a problem "passing" an argument with the "known" value to the function. Correct?

For example, let's say you want to run "some" code when the user selects an item from a Combobox. Then, you might decide to use the Combobox's AfterUpdatevent. If you do, then at that point, you know "which" combobox's event you used; and therefore, you would also know its name when you called the function. Hope it makes sense...
 

Users who are viewing this thread

Top Bottom