The previous form's LostFocus event will fire...if you're shifting focus.
In the Lostfocus event you can maybe set a global flag determining the last form that had the focus. The form receiving the focus, queries that flag & sets it to itself since it now has focus.
can you show me some code? this is what i have as far as form layout.(MDI) there is a rtf form. you click properties, another form pops up and gaines focus, it needs to know what the name of the form that last had the focus is.
whenever i do gblLastFormName.color = green or anything like that, it gives an error, something about it being an invalid container or something like that.
I think I know what you after. Put this code in a module.
Public Function CallingForm(ByVal hWnd As Long) As Form
'Return the Form that launched the given Window
Dim lHwnd As Long
Dim oForm As Form
'get the Handle of the Window that Loaded this Window
lHwnd = GetNextWindow(hWnd, GW_HWNDNEXT)
'Find a match in the "Forms" collection
'and return a reference to it
For Each oForm In Forms
If oForm.hWnd = lHwnd Then
Set CallingForm = oForm
Exit For
End If
Next
End Function
And then you will reference (lets say a text box on that form) this previous active form like this
YES! thats exactly what i needed, but one question, the form that i want to call the text(rtf) box form is a new version of another form, do you understand what i mean? Dim MyForm as New ThisIsMyForm. So will it work then? Because every new *file-new* form that i create, is named MyForm. So will this still work?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.