I have a Search form that finds a record and when I return to the main form I need to run a Sub to update some list boxes. Tried many Events and can't get it to work. I know the Sub works because I can use a test button to run Sub.
Thanks,
Tom
I have a Search form that finds a record and when I return to the main form I need to run a Sub to update some list boxes. Tried many Events and can't get it to work. I know the Sub works because I can use a test button to run Sub.
Thanks,
Tom
How about the activate event of the form, or the close event of the search form?
Can I run a Sub for the Main form on a close of the Search form? I did tryactivate event.
You should be able to if you make it public.
Ok, that makes sense! Thanks!
No problem, post back if you get stuck.
I've been researching Modules and Public Subs. I quess I need to a standard Modules to make it Public. Now if I have calls in my Sub, I would guess they would have to be in the Module too. It there any good web pages on changing a Sub to a Public Module?
Thanks!
It can but doesn't need to be. I just tested a button on a form, changing it from Private to Public:
Public Sub Command3_Click()
Then I called that button's code from another button:
Code:Private Sub Command22_Click() Command3_Click End Sub
I want to run the Sub in form1 when I close form2. If I change it to Public I get "Sub not defined".
You'd need the full reference from another form, like:
Forms!form1.Command3_Click
I tried Forms!frmSearch.CheckValue. I need this to work in the Search form on closing. Do I need a Module? or Public Sub?
Private Sub Form_Close()
Call CheckValue
End Sub
The sub being called needs to be public. Say it's in form1. The sub you want to call in form1 is Command3_Click.
From another form the syntax to run that command (form1 must be loaded, of course)
Call Form_form1.Command3_Click
Use that exact format. Prefix is FORM_ not FORMS!
I'll get out of the way. What I posted was tested and did work.
Forms!form1.Command3_Click
Paul, didn't mean to come across as critical. Just stating what I have used for years that works for me.I'll get out of the way.
Sorry, something I'm not getting.
Code in frmSearch
Code in frmPartsCode:Private Sub Form_Close() 'Code to run on close Form!frmParts.CheckValue End Sub
Code:Public Sub CheckValue() 'Case Select to remove Text On Error Resume Next Select Case Me.cboType.Value Case "Capacitor" Call addtext Case "Resistor" Call removetext Case "Diode" Call removetext Case "Transistor" Call removetext Case "IC" Call removetext Case "Hardware" Call removetext Case "Misc" Call removetext Case "Board" Call removetext Case Else Call cmdLast_Click 'Call removetext End Select End Sub