arihan1511
New Member
Good Evening Members
I am Building a user form to store my contacts.By using the user form I can edit,search,view previous or next contact or add new contact
There is a command button "Add" which on clicking updates sheet with any modification made on user form.This Button works beautifully when record is viewed and modified using next or previous button.
For 10-15 contacts navigating through contacts is possible but for large no of contacts a search function is created using combobox1 change event function.
But the moment I search contact using Combobox1 and then try to update sheet with modification made in the found contact ,"Add" button fails to update the Sheet. In fact Add button neither works nor shows any error after search procedure using combobox 1 and Userform has to be restarted to update any contacts
I am stuck up at this stage
Can anyone Guide me where I have gone wrong, why Add button stops working after running search VBA change event using Combobox1?
Any help in this regard will be appreciable......
Attached file for reference
For Privacy Issue Name and No have been modified
I am Building a user form to store my contacts.By using the user form I can edit,search,view previous or next contact or add new contact
There is a command button "Add" which on clicking updates sheet with any modification made on user form.This Button works beautifully when record is viewed and modified using next or previous button.
For 10-15 contacts navigating through contacts is possible but for large no of contacts a search function is created using combobox1 change event function.
But the moment I search contact using Combobox1 and then try to update sheet with modification made in the found contact ,"Add" button fails to update the Sheet. In fact Add button neither works nor shows any error after search procedure using combobox 1 and Userform has to be restarted to update any contacts
I am stuck up at this stage
Code:
Private Sub Add_Click()
Worksheets("OPD").AutoFilterMode = False
Dim FoundCell As Range
Dim Search As String
Search = VisitDate.Value
Set FoundCell = Sheets("OPD").Columns(1).Find(Search, _
LookIn:=xlValues, _
LookAt:=xlWhole)
If FoundCell Is Nothing Then
MsgBox "No Record Found in Database", vbInformation, "Contacts"
Exit Sub
Else
'Dim lastrow As Long
FoundCell.Select
UpdateData
MsgBox "Record Updated in Database", vbInformation, "Contacts"
ActiveWorkbook.Save
End If
End Sub
Code:
Private Sub ComboBox1_Change()
Worksheets("OPD").AutoFilterMode = False
Dim FoundCell As Range
Dim Search As String
Search = ComboBox1.Value
Set FoundCell = Sheets("OPD").Columns(1).Find(Search, _
LookIn:=xlValues)
If FoundCell Is Nothing Then
MsgBox "No Record Found in Database", vbInformation, "Contacts"
Exit Sub
Else
'Dim lastrow As Long
FoundCell.Select
GetData
TotalRec.Value = Range(Columns("A:A").SpecialCells(xlCellTypeVisible).Address).SpecialCells(xlCellTypeConstants, 3).Count - 1
End If
End Sub
Can anyone Guide me where I have gone wrong, why Add button stops working after running search VBA change event using Combobox1?
Any help in this regard will be appreciable......
Attached file for reference
For Privacy Issue Name and No have been modified