Well, this one is "easy".
VB provides the option to display forms modal. Default option is modeless however.
Just use
frmSomeForm.Show vbModal. Code will only be executed after this statement, until frmSomeForm is hidden or unload again.
BTW, I personally didn't really think that passing back the me-reference or casting an event with it would be that bad. I mean, why not let your function return the link to a text-control?
Anyway, I didn't exactly understand how you tried to solve that anyway.
So a nice method for you would be:
Code:
' This inside your modal edit dialog, let's call it frmUserEdit:
' Damnit I think it's gotta be private, but maybe without a keyword is ok? Or try public. Whatever:
Function GetEditFromUser() As String
Me.Show vbModal ' the second parameter is "OwnerForm", sometimes you specify "Me"
'I don't know exactly when. Maybe you wanna pass the OwnerForm as reference to this function?
' The code in here will only be exited, once you decide to unload / hide the Form... Choose appropriate.
GetEditFromUser = txtEdit.Text
End Function
I noticed this might be bullshit, to put the modal-calling function inside the modal-form itself. If it's unload, the Text-Information will be gone.
Probably better put the whole thing in a Module. Then:
Code:
' In a module:
Public Function GetEditFromUser(ByRef frmModalEditDialog as Form, ByRef frmOwnerForm as Form) as String
frmModalEditDialog.Show vbModal, frmOwnerForm
' In that form, make sure that "Form_Show" or "Form_Load" does everything is need.
' In "cmdOk_Click" or so, call Me.Hide
' This requires the passed form to have a text-control named this way, obviously
GetEditFromUser = frmModalEditDialog.txtEdit.Text
' Now it is optional to Unload the form, depends on how often you wanna use it etc...
Unload frmModalEditDialog
End Function