Hi all,
I have two forms; frmTelephoneSearch and frmAddNewContact
On frmTelephoneSearch is a button that opens frmAddNewContact
in frmTelephoneSearch i have a private sub named; UserForm_Initialize()
I got a button on frmAddNewContact with this code in it;
Now i would like to add in this code that private sub named; UserForm_Initialize() is run that is in frmTelephoneSearch.
How to do this?
I have two forms; frmTelephoneSearch and frmAddNewContact
On frmTelephoneSearch is a button that opens frmAddNewContact
in frmTelephoneSearch i have a private sub named; UserForm_Initialize()
I got a button on frmAddNewContact with this code in it;
Code:
Private Sub cmdAddNewContact_Click()On Error GoTo cmdAdd_Click_Error
'Go To Error if an error occurs
If Me.txtFullname.value = "" Then
Call MsgBox("The required fields are not complete", vbInformation, "Edit Contact")
Exit Sub
End If
If Worksheets("Telephone").Range("A2").value = "" Then
Worksheets("Telephone").Range("A2:F2").FormulaArray = "1"
End If
'set the destination range
Set Drng = Worksheets("Telephone").Range("A1")
'move the values without selecting
Drng.End(xlDown).Offset(1, 0).value = Me.txtFullname.value
Drng.End(xlDown).Offset(0, 1).value = Me.txtDepartment.value
Drng.End(xlDown).Offset(0, 2).value = Me.txtEmailadress.value
Drng.End(xlDown).Offset(0, 3).value = Me.txtPhone.value
Drng.End(xlDown).Offset(0, 6).value = Drng.End(xlDown).Offset(-1, 6).value + 1
'give the "all OK signal"
Call MsgBox("A new contact has been added", vbInformation, "Add Contact")
'sort the data
SortIt
Unload Me
On Error GoTo 0
Exit Sub
'if error occurs then show me exactly where the error occurs
cmdAdd_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdAdd_Click of Form AddNewContact"
End Sub
Now i would like to add in this code that private sub named; UserForm_Initialize() is run that is in frmTelephoneSearch.
How to do this?