I have two userforms.
The first (frmRecords) shows each row as a record with navigation buttons (First, Next, Previous, Last). It also has a text box giving the number of the record (i.e. 1) and label that gives the total number of records (i.e. of 7). This works correctly and allows the user to cycle through all the records in the worksheet, edit and add new ones.
The second (frmSearch) allows filters to be applied to the worksheet - this is working correctly.
When the second closes, the first is reopened, however, it shows all the records, not the filtered recordset!
How do I get frmRecords to only show the filtered records in the worksheet?
I used the Office Dev example to help me construct the userform I am assuming I need to add some qualification in here as it is called when the userform is initialized.
The first (frmRecords) shows each row as a record with navigation buttons (First, Next, Previous, Last). It also has a text box giving the number of the record (i.e. 1) and label that gives the total number of records (i.e. of 7). This works correctly and allows the user to cycle through all the records in the worksheet, edit and add new ones.
The second (frmSearch) allows filters to be applied to the worksheet - this is working correctly.
When the second closes, the first is reopened, however, it shows all the records, not the filtered recordset!
How do I get frmRecords to only show the filtered records in the worksheet?
I used the Office Dev example to help me construct the userform I am assuming I need to add some qualification in here as it is called when the userform is initialized.
Code:
Private Sub GetData()
'error handling
'GetData copies the data from the currently active worksheet to the user form.
'After declaring a temporary variable r to hold the current row,
'the routine verifies that the value in the RowNumber control is numeric.
Dim r As Long
LastRow = FindLastRow
If IsNumeric(RowNumber.Text) Then
r = CLng(RowNumber.Text)
'Knowing that RowNumber contains a numeric value, the CLng function is used to convert
'the value in RowNumber into the variable r. The rest of the code merely uses r to
'extract the information from the proper row and copy it to the correct field.
Else
ClearData
'ClearData routine simply assigns an empty string to each field on the form to clear out
'any values that might have already been displayed on the form.
MsgBox "Illegal row number"
Exit Sub
End If
'Populate all the controls on the userform
Index.Text = Cells(r, 1)
Category1.Text = Cells(r, 2)
Contractref.Text = Cells(r, 3)
Title.Text = Cells(r, 4)
Description.Text = Cells(r, 5)
Contracttype1.Text = Cells(r, 6)
Status1.Text = Cells(r, 7)
Targetdate = Cells(r, 8)
Tenderlist = Cells(r, 9)
Subcontract = Cells(r, 10)
Value1 = Cells(r, 11)
DisableSave
'error handling
End Sub