I created a userform1 for data entry into my worksheet. I would like to add code to add a Find button that would find a report number in my workssheet and repopulate the userform1 pulling in the entire row. This would allow me to edit the record. i would then like to update to row with the new data. Below is the code, Any help would be appreciated.
Private Sub SubmitButton1_Click()
Dim i As Integer
i = 1
While ThisWorkbook.Worksheets("Disciplinary Report Log").Range("A" & i).Value <> ""
i = i + 1
Wend
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("A" & i).Value = ReportNumber.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("B" & i).Value = InmateName.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("C" & i).Value = InmateNumber.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("D" & i).Value = Offense.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("E" & i).Value = ClassofOffense.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("F" & i).Value = DateofOffense.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("G" & i).Value = DateofFinalImposition.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("H" & i).Value = InmatePlea.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("I" & i).Value = Investigator.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("J" & i).Value = Coordinator.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("K" & i).Value = HearingOfficer.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("L" & i).Value = Sanction.Value
datavalidation
End Sub
Sub UserForm_Initialize()
Offense.List = Array("ALTERATION OF A SPECIMEN", "ARSON", "ASSAULT", "ASSAULT ON DOC EMPLOYEE", "BARTERING", "BRIBERY", "CAUSING A DISBURENCE", "CONTRABAND CLASS A", _
"CONTABAND, CLASS B", "CREATING A DISTURBANCE", "DESTRUCTION OF PROPERTY", "DISOBEYING A DIRECT ORDER", "ESCAPE", "ESCAPE FROM PCS SUPERVISION", "FALSELY REPORTING AND INCIDENT", _
"FELONIOUS MISCONDUCT", "FIGHTING", "GAMBILING", "GIVING FALSE INFORMATION", "FLAGRANT DISOBEDIENCE", "HOSTAGE HOLDING", "HOSTAGE HOLDONG OF DOC EMPLOYEE", "IMPEDING ORDER", _
"INSULTING LANGUAGE", "INTERFERING WITH SAFETY AND SECURITY", "INTOXICATION", "LINGERING", "MISDEMEANOR MISCONDUCT", "OUT OF PLACE", "POSSESION OF SEXUALLY EXPLICIT MATERIAL", "PUBLIC INDECENCY", _
"REFUSAL OR REMOVAL OF AN INSTITUTIONAL PROGRAM OR POLICY", "REFUSAL TO GIVE A SPECIMEN", "REFUSING HOUSING", "RIOT", "SECRETING IDENTITY", _
"SECURITY RISK GROUP AFFILITATION", "SECURITY TAMPERING", "SELF MUTILATION", "SEXUAL MISCONDUCT", "THEFT, CLASS A", "THEFT, CLASS B", "THREATS", "VIOLATION OF PROGRAM PROVISIONS")
ClassofOffense.List = Array("A", "B", "C")
InmatePlea.List = Array("GUILTY", "NOT GUILTY")
End Sub
Private Sub datavalidation()
' If ReportNumber.Value = "" Then
' MsgBox "Sorry, Report Number can not be blank."
'Exit Sub
'End If
If InmateName.Value = "" Then
MsgBox "Sorry, Inmate Name cannot be blank,"
Exit Sub
End If
If InmateNumber.Value = "" Then
MsgBox "Sorry, Inmate Number cannot be blank,"
Exit Sub
End If
If Offense = "" Then
MsgBox "Please select Offense,"
Exit Sub
End If
If ClassofOffense.Value = "" Then
MsgBox "Sorry, Class of Offense cannot be blank,"
Exit Sub
End If
If DateofOffense.Value = "" Then
MsgBox "Sorry, Dateof Offense cannot be blank,"
Exit Sub
End If
'If DateofFinalImposition.Value = "" Then
' MsgBox "Sorry, Date of Final Imposition cannot be blank,"
'Exit Sub
'End If
'If InmatePlea.Value = "" Then
' MsgBox "Sorry, Inmate Plea cannot be blank,"
'Exit Sub
'End If
If Investigator = "" Then
MsgBox "Sorry, Investigator cannot be blank,"
Exit Sub
End If
'If Coordinator = "" Then
' MsgBox "Sorry, Coordinator cannot be blank,"
'Exit Sub
'End If
'If HearingOfficer = "" Then
' MsgBox "Sorry, Hearing Officer cannot be blank,"
'Exit Sub
'End If
'If Sanction = "" Then
' MsgBox "Sorry, Sanction cannot be blank,"
'Exit Sub
'End If
Exit Sub
End Sub
Private Sub ExitButton_Click()
Unload Me
End Sub
Private Sub ClearButton_Click()
'ReportNumber.Value = ""
InmateName.Value = ""
InmateNumber.Value = ""
Offense.Value = ""
ClassofOffense.Value = ""
DateofOffense.Value = ""
DateofFinalImposition.Value = ""
InmatePlea.Value = ""
Investigator.Value = ""
Coordinator.Value = ""
HearingOfficer.Value = ""
Sanction.Value = ""
End Sub
Private Sub SubmitButton1_Click()
Dim i As Integer
i = 1
While ThisWorkbook.Worksheets("Disciplinary Report Log").Range("A" & i).Value <> ""
i = i + 1
Wend
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("A" & i).Value = ReportNumber.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("B" & i).Value = InmateName.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("C" & i).Value = InmateNumber.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("D" & i).Value = Offense.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("E" & i).Value = ClassofOffense.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("F" & i).Value = DateofOffense.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("G" & i).Value = DateofFinalImposition.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("H" & i).Value = InmatePlea.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("I" & i).Value = Investigator.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("J" & i).Value = Coordinator.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("K" & i).Value = HearingOfficer.Value
ThisWorkbook.Worksheets("Disciplinary Report Log").Range("L" & i).Value = Sanction.Value
datavalidation
End Sub
Sub UserForm_Initialize()
Offense.List = Array("ALTERATION OF A SPECIMEN", "ARSON", "ASSAULT", "ASSAULT ON DOC EMPLOYEE", "BARTERING", "BRIBERY", "CAUSING A DISBURENCE", "CONTRABAND CLASS A", _
"CONTABAND, CLASS B", "CREATING A DISTURBANCE", "DESTRUCTION OF PROPERTY", "DISOBEYING A DIRECT ORDER", "ESCAPE", "ESCAPE FROM PCS SUPERVISION", "FALSELY REPORTING AND INCIDENT", _
"FELONIOUS MISCONDUCT", "FIGHTING", "GAMBILING", "GIVING FALSE INFORMATION", "FLAGRANT DISOBEDIENCE", "HOSTAGE HOLDING", "HOSTAGE HOLDONG OF DOC EMPLOYEE", "IMPEDING ORDER", _
"INSULTING LANGUAGE", "INTERFERING WITH SAFETY AND SECURITY", "INTOXICATION", "LINGERING", "MISDEMEANOR MISCONDUCT", "OUT OF PLACE", "POSSESION OF SEXUALLY EXPLICIT MATERIAL", "PUBLIC INDECENCY", _
"REFUSAL OR REMOVAL OF AN INSTITUTIONAL PROGRAM OR POLICY", "REFUSAL TO GIVE A SPECIMEN", "REFUSING HOUSING", "RIOT", "SECRETING IDENTITY", _
"SECURITY RISK GROUP AFFILITATION", "SECURITY TAMPERING", "SELF MUTILATION", "SEXUAL MISCONDUCT", "THEFT, CLASS A", "THEFT, CLASS B", "THREATS", "VIOLATION OF PROGRAM PROVISIONS")
ClassofOffense.List = Array("A", "B", "C")
InmatePlea.List = Array("GUILTY", "NOT GUILTY")
End Sub
Private Sub datavalidation()
' If ReportNumber.Value = "" Then
' MsgBox "Sorry, Report Number can not be blank."
'Exit Sub
'End If
If InmateName.Value = "" Then
MsgBox "Sorry, Inmate Name cannot be blank,"
Exit Sub
End If
If InmateNumber.Value = "" Then
MsgBox "Sorry, Inmate Number cannot be blank,"
Exit Sub
End If
If Offense = "" Then
MsgBox "Please select Offense,"
Exit Sub
End If
If ClassofOffense.Value = "" Then
MsgBox "Sorry, Class of Offense cannot be blank,"
Exit Sub
End If
If DateofOffense.Value = "" Then
MsgBox "Sorry, Dateof Offense cannot be blank,"
Exit Sub
End If
'If DateofFinalImposition.Value = "" Then
' MsgBox "Sorry, Date of Final Imposition cannot be blank,"
'Exit Sub
'End If
'If InmatePlea.Value = "" Then
' MsgBox "Sorry, Inmate Plea cannot be blank,"
'Exit Sub
'End If
If Investigator = "" Then
MsgBox "Sorry, Investigator cannot be blank,"
Exit Sub
End If
'If Coordinator = "" Then
' MsgBox "Sorry, Coordinator cannot be blank,"
'Exit Sub
'End If
'If HearingOfficer = "" Then
' MsgBox "Sorry, Hearing Officer cannot be blank,"
'Exit Sub
'End If
'If Sanction = "" Then
' MsgBox "Sorry, Sanction cannot be blank,"
'Exit Sub
'End If
Exit Sub
End Sub
Private Sub ExitButton_Click()
Unload Me
End Sub
Private Sub ClearButton_Click()
'ReportNumber.Value = ""
InmateName.Value = ""
InmateNumber.Value = ""
Offense.Value = ""
ClassofOffense.Value = ""
DateofOffense.Value = ""
DateofFinalImposition.Value = ""
InmatePlea.Value = ""
Investigator.Value = ""
Coordinator.Value = ""
HearingOfficer.Value = ""
Sanction.Value = ""
End Sub