I have created a form because there are 1000's of details that are going to be inputted.
As you can see below i am searching for a PO NUMBER which is in the spreadsheet.
But it has come back saying it can not find a record.
Below is the VBA Coding in the module1
If anyone could help me solve this issue I will be truly grateful and also this will form / excel form will help out many children within the healthcare sector.
As you can see below i am searching for a PO NUMBER which is in the spreadsheet.
But it has come back saying it can not find a record.
Below is the VBA Coding in the module1
VBA Code:
Option Explicit
Public EnableEvents As Boolean
Private Sub cmbSearchColumn_Change()
If Me.EnableEvents = False Then Exit Sub
If Me.cmbSearchColumn.Value = "All" Then
Call Reset
Else
Me.txtSearch.Value = ""
Me.txtSearch.Enabled = True
Me.cmdSearch.Enabled = True
End If
End Sub
Private Sub cmdDelete_Click()
Dim Irow As Long
If selected_list = 0 Then
MsgBox "No row is selected.", vbOKOnly + vbInformation, "Delete"
Exit Sub
End If
Dim i As VbMsgBoxResult
i = MsgBox("Do you want to delete the selected record?", vbYesNo + vbQuestion, "confirmation")
If i = vbNo Then Exit Sub
Irow = Application.WorksheetFunction.Match(Me.lstDatabase.List(Me.lstDatabase.ListIndex, 0), _
ThisWorkbook.Sheets("PODatabase").Range("A:A"), 0)
ThisWorkbook.Sheets("PODatabase").Rows(Irow).Delete
Call Reset
MsgBox "Selected record has been deleted.", vbOKOnly + vbInformation, "Deleted"
End Sub
Private Sub cmdEdit_Click()
If selected_list = 0 Then
MsgBox "No Row Selected", vbOKOnly + vbInformation, "Edit"
Exit Sub
End If
Me.txtRowNumber.Value = Application.WorksheetFunction.Match(Me.lstDatabase.List(Me.lstDatabase.ListIndex, 0), _
ThisWorkbook.Sheets("Database").Range("a:A"), 0)
Me.cmbCompany.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 1)
Me.cmbtype.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 2)
Me.txtName.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 3)
Me.txtNHS.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 4)
Me.txtpostcode.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 5)
Me.cmbCCG.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 6)
Me.txtReqNo.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 7)
Me.txtPONO.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 8)
MsgBox "Please Make the required changes and click on 'Save' button to update.", vbOKOnly + vbInformation, "Edit"
End Sub
Private Sub cmdFullScreen_Click()
Call Maximize_Restore
End Sub
Private Sub cmdReset_Click()
Dim msgValue As VbMsgBoxResult
msgValue = MsgBox("Do you want to reset the form?", vbYesNo + vbInformation, "Comfirmation")
If msgValue = vbNo Then Exit Sub
Call Reset
End Sub
Private Sub cmdSave_Click()
Dim msgValue As VbMsgBoxResult
msgValue = MsgBox("Do you want to save the data?", vbYesNo + vbInformation, "Comfirmation")
If msgValue = vbNo Then Exit Sub
Call Submit
Call Reset
End Sub
Private Sub cmdSearch_Click()
If Me.txtSearch.Value = "" Then
MsgBox "Please enter the search value.", vbOKOnly + vbInformation, "search"
Exit Sub
End If
Call SearchData
End Sub
Private Sub UserForm_Initialize()
Call Reset
End Sub
Rich (BB code):
Option Explicit
Public EnableEvents As Boolean
Private Sub cmbSearchColumn_Change()
If Me.EnableEvents = False Then Exit Sub
If Me.cmbSearchColumn.Value = "All" Then
Call Reset
Else
Me.txtSearch.Value = ""
Me.txtSearch.Enabled = True
Me.cmdSearch.Enabled = True
End If
End Sub
Private Sub cmdDelete_Click()
Dim Irow As Long
If selected_list = 0 Then
MsgBox "No row is selected.", vbOKOnly + vbInformation, "Delete"
Exit Sub
End If
Dim i As VbMsgBoxResult
i = MsgBox("Do you want to delete the selected record?", vbYesNo + vbQuestion, "confirmation")
If i = vbNo Then Exit Sub
Irow = Application.WorksheetFunction.Match(Me.lstDatabase.List(Me.lstDatabase.ListIndex, 0), _
ThisWorkbook.Sheets("PODatabase").Range("A:A"), 0)
ThisWorkbook.Sheets("PODatabase").Rows(Irow).Delete
Call Reset
MsgBox "Selected record has been deleted.", vbOKOnly + vbInformation, "Deleted"
End Sub
Private Sub cmdEdit_Click()
If selected_list = 0 Then
MsgBox "No Row Selected", vbOKOnly + vbInformation, "Edit"
Exit Sub
End If
Me.txtRowNumber.Value = Application.WorksheetFunction.Match(Me.lstDatabase.List(Me.lstDatabase.ListIndex, 0), _
ThisWorkbook.Sheets("Database").Range("a:A"), 0)
Me.cmbCompany.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 1)
Me.cmbtype.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 2)
Me.txtName.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 3)
Me.txtNHS.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 4)
Me.txtpostcode.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 5)
Me.cmbCCG.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 6)
Me.txtReqNo.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 7)
Me.txtPONO.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 8)
MsgBox "Please Make the required changes and click on 'Save' button to update.", vbOKOnly + vbInformation, "Edit"
End Sub
Private Sub cmdFullScreen_Click()
Call Maximize_Restore
End Sub
Private Sub cmdReset_Click()
Dim msgValue As VbMsgBoxResult
msgValue = MsgBox("Do you want to reset the form?", vbYesNo + vbInformation, "Comfirmation")
If msgValue = vbNo Then Exit Sub
Call Reset
End Sub
Private Sub cmdSave_Click()
Dim msgValue As VbMsgBoxResult
msgValue = MsgBox("Do you want to save the data?", vbYesNo + vbInformation, "Comfirmation")
If msgValue = vbNo Then Exit Sub
Call Submit
Call Reset
End Sub
Private Sub cmdSearch_Click()
If Me.txtSearch.Value = "" Then
MsgBox "Please enter the search value.", vbOKOnly + vbInformation, "search"
Exit Sub
End If
Call SearchData
End Sub
Private Sub UserForm_Initialize()
Call Reset
End Sub
If anyone could help me solve this issue I will be truly grateful and also this will form / excel form will help out many children within the healthcare sector.