Hello All,
I cannot enter data in the text box circled below. The error message is near the end and is marked 'Error message here***. The Text box is named txtSearch.
Thank you,
Tony
I cannot enter data in the text box circled below. The error message is near the end and is marked 'Error message here***. The Text box is named txtSearch.
VBA Code:
Option Explicit
Sub Reset()
Dim iRow As Long
iRow = [Counta(Database!A:A)] 'identifying the last row'
With frmform1
.txtnumber.Value = ""
.Txttitle.Value = ""
.lbsystem.Clear
.lbsystem.AddItem "ACS"
.lbsystem.AddItem "Archive Data"
.lbsystem.AddItem "ATDS"
.lbsystem.AddItem "Autocapture Testbed"
.lbsystem.AddItem "AVN"
.lbsystem.AddItem "C&DH"
.lbsystem.AddItem "CBS"
.lbsystem.AddItem "COMLIDAR"
.lbsystem.AddItem "COMM"
.lbsystem.AddItem "COMSEC"
.lbsystem.AddItem "EGSE"
.lbsystem.AddItem "EGSE (Flight I&T)"
.lbsystem.AddItem "EPS"
.lbsystem.AddItem "FlatSat"
.lbsystem.AddItem "FSW"
.lbsystem.AddItem "HFCS"
.lbsystem.AddItem "L7 Mockups (Flight I&T)"
.lbsystem.AddItem "Landsat 7"
.lbsystem.AddItem "LIDAR"
.lbsystem.AddItem "MECH"
.lbsystem.AddItem "MGSE (Flight I&T)"
.lbsystem.AddItem "PCC"
.lbsystem.AddItem "PROP"
.lbsystem.AddItem "PSU"
.lbsystem.AddItem "PTS"
.lbsystem.AddItem "RDT"
.lbsystem.AddItem "REU"
.lbsystem.AddItem "ROBOT"
.lbsystem.AddItem "RPO"
.lbsystem.AddItem "RPO Testbed"
.lbsystem.AddItem "SC"
.lbsystem.AddItem "SCTHRM"
.lbsystem.AddItem "Servicing Payload (PYLD)"
.lbsystem.AddItem "Serviving Testbed"
.lbsystem.AddItem "Simulators"
.lbsystem.AddItem "SP/SV/SC SPIDER GSE"
.lbsystem.AddItem "Spave Vehicle Management"
.lbsystem.AddItem "SPIDER"
.lbsystem.AddItem "SPINT"
.lbsystem.AddItem "STR"
.lbsystem.AddItem "SVINT"
.lbsystem.AddItem "Testbeds"
.lbsystem.AddItem "THRM"
.lbsystem.AddItem "TOOL"
.lbsystem.AddItem "VDSU"
.lbsystem.AddItem "VSS"
.optyes.Value = False
.optno.Value = False
.lbdefectcode.Clear
.lbdefectcode.AddItem "10 - Solder Defect"
.lbdefectcode.AddItem "20 - Contamination"
.lbdefectcode.AddItem "30 - Shrink Tubing Missing"
.lbdefectcode.AddItem "40 - Not Built to Specification/Drawing"
.lbdefectcode.AddItem "50 - Dimensions Out of Tolerance"
.lbdefectcode.AddItem "60 - Failed Test"
.lbdefectcode.AddItem "70 - Accept"
.lbdefectcode.AddItem "80 - Damaged"
.lbdefectcode.AddItem "90 - Documentation Error"
.lbexpected.Clear
.lbexpected.AddItem ".5"
.lbexpected.AddItem "1"
.lbexpected.AddItem "1.5"
.lbexpected.AddItem "2"
.lbexpected.AddItem "2.5"
.lbexpected.AddItem "3"
.lbexpected.AddItem "3.5"
.lbexpected.AddItem "4"
.lbexpected.AddItem "4.5"
.lbexpected.AddItem "5"
.lbexpected.AddItem "5.5"
.lbexpected.AddItem "6"
.lbexpected.AddItem "6.5"
.lbexpected.AddItem "7"
.lbexpected.AddItem "7.5"
.lbexpected.AddItem "8"
.lbexpected.AddItem "8.5"
.lbexpected.AddItem "9"
.lbexpected.AddItem "9.5"
.lbexpected.AddItem "10"
.lbexpected.AddItem "10.5"
.lbexpected.AddItem "11"
.lbexpected.AddItem "11.5"
.lbexpected.AddItem "12"
.lbactual.Clear
.lbactual.AddItem ".5"
.lbactual.AddItem "1"
.lbactual.AddItem "1.5"
.lbactual.AddItem "2"
.lbactual.AddItem "2.5"
.lbactual.AddItem "3"
.lbactual.AddItem "3.5"
.lbactual.AddItem "4"
.lbactual.AddItem "4.5"
.lbactual.AddItem "5"
.lbactual.AddItem "5.5"
.lbactual.AddItem "6"
.lbactual.AddItem "6.5"
.lbactual.AddItem "7"
.lbactual.AddItem "7.5"
.lbactual.AddItem "8"
.lbactual.AddItem "8.5"
.lbactual.AddItem "9"
.lbactual.AddItem "9.5"
.lbactual.AddItem "10"
.lbactual.AddItem "10.5"
.lbactual.AddItem "11"
.lbactual.AddItem "11.5"
.lbactual.AddItem "12"
.txtproblem.Value = ""
.txtnotes.Value = ""
.txtRowNumber.Value = ""
'Below code are associated with Search Feature
Call Add_SearchColumn
ThisWorkbook.Sheets("Database").AutoFilterMode = False
ThisWorkbook.Sheets("SearchData").AutoFilterMode = False
ThisWorkbook.Sheets("SearchData").Cells.Clear
'-----------------------------------------------
.lbdatabase.ColumnCount = 12
.lbdatabase.ColumnHeads = True
.lbdatabase.ColumnWidths = "40,70,55,55,20,20,40,40,40,40,40,40"
If iRow > 1 Then
.lbdatabase.RowSource = "Database!A2:L" & iRow
Else
.lbdatabase.RowSource = "Database!A2:L2"
End If
End With
End Sub
Sub Submit()
Dim Sh As Worksheet
Dim iRow As Long
Set Sh = ThisWorkbook.Sheets("Database")
If frmform1.txtRowNumber.Value = " " Then
iRow = [Counta(Database!A:A)] + 1
Else
iRow = frmform1.txtRowNumber.Value
End If
With Sh
.Cells(iRow, 1) = iRow - 1
.Cells(iRow, 2) = frmform1.txtnumber.Value
.Cells(iRow, 3) = frmform1.Txttitle.Value
.Cells(iRow, 4) = frmform1.lbsystem.Value
.Cells(iRow, 5) = IIf(frmform1.optyes.Value = True, "Y", "N")
.Cells(iRow, 6) = frmform1.lbdefectcode.Value
.Cells(iRow, 7) = frmform1.lbexpected.Value
.Cells(iRow, 8) = frmform1.lbactual.Value
.Cells(iRow, 9) = frmform1.txtproblem.Value
.Cells(iRow, 10) = frmform1.txtnotes.Value
.Cells(iRow, 11) = Application.UserName
.Cells(iRow, 12) = [Text(Now(), "MM-DD-YYYY HH:MM:SS")]
End With
End Sub
Sub Show_Form()
frmform1.Show
End Sub
Function Selected_List() As Long
Dim i As Long
Selected_List = 0
For i = 0 To frmform1.lbdatabase.ListCount - 1
If frmform1.lbdatabase.Selected(i) = True Then
Selected_List = i + 1
Exit For
End If
Next i
End Function
Sub Add_SearchColumn()
frmform1.EnableEvents = False
With frmform1.cmbSearchcolumn
.Clear
.AddItem "All"
.AddItem "WOA Num"
.AddItem "WOA Title"
.AddItem "System"
.AddItem "PR"
.AddItem "Defect"
.AddItem "Expected"
.AddItem "Actual"
.AddItem "Prob Desc"
.AddItem "Notes"
.AddItem "QE"
.AddItem "Date"
.Value = "All"
End With
frmform1.EnableEvents = True
frmform1.txtSearch.Value = ""
frmform1.txtSearch.Enabled = False
frmform1.cmdSearch = False
End Sub
Sub SearchData()
Application.ScreenUpdating = False
Dim shDatabase As Worksheet 'Database sheet
Dim shSearchData As Worksheet 'SearchData sheet
Dim iColumn As Integer 'To hold the selected column number in Database sheet
Dim iDatabaseRow As Long 'To store the last non-blank row number available in Database
Dim iSearchRow As Long 'To hold the last non-blank row number in SearchData Sheet
Dim sColumn As String 'To store the column selection
Dim sValue As String 'To hold the search text value
Set shDatabase = ThisWorkbook.Sheets("Database")
Set shSearchData = ThisWorkbook.Sheets("SearchData")
iDatabaseRow = ThisWorkbook.Sheets("Database").Range("A" & Application.Rows.Count).End(xlUp).Row
sColumn = frmform1.cmbSearchcolumn.Value
sValue = frmform1.txtSearch.Value 'ERROR IS HERE************************************
iColumn = Application.WorksheetFunction.Match(sColumn, shDatabase.Range("A1:L1"), 0)
'Remove filter from Database worksheet
If shDatabase.AutoFilterMode = True Then
shDatabase.AutoFilterMode = False
End If
'Apply filter on Database worksheet modified
If sColumn = "Date" Then
shDatabase.Range("A1:L" & iDatabaseRow).AutoFilter Field:=iColumn, Criteria1:="=" & sValue
Else
shDatabase.Range("A1:L" & iDatabaseRow).AutoFilter Field:=iColumn, Criteria1:="*" & sValue & "*"
End If
If Application.WorksheetFunction.Subtotal(3, shDatabase.Range("C:C")) >= 2 Then
'Code to remove the previous data from SearchData Worksheet
shSearchData.Cells.Clear
shDatabase.AutoFilter.Range.Copy shSearchData.Range("A1")
Application.CutCopyMode = False
iSearchRow = shSearchData.Range("A" & Application.Rows.Count).End(xlUp).Row
frmform1.lbdatabase.ColumnCount = 12
frmform1.lbdatabase.ColumnWidths = "40,40,40,40,40,40,40,40,40,40,40,40"
If iSearchRow > 1 Then
frmform1.lbdatabase.RowSource = "SearchData!A2:L" & iSearchRow
MsgBox "Records found."
End If
Else
MsgBox "No record found."
End If
shDatabase.AutoFilterMode = False
Application.ScreenUpdating = True
End Sub
Thank you,
Tony