seanpears99
New Member
- Joined
- Aug 22, 2006
- Messages
- 21
Hi everyone, been ages since I have posted on here so hopefully someone can help.
I have created a UserForm for a dependency management system and within each record I want the user to be able to use the user form to search using 7 criteria however they can use more than one criteria at once.
For example, they can search on the Unique ID only, but they can also search on Dependency Supplier Name, Supplier Program and Supplier Project. Other fields are Dependency Receiver Name, Dependency Program and Dependency Project.
I am controlling the frames on the user form to only allow the user to search on the Unique ID only, the Supplier fields only (3 of them) or the Receiver fields (3 of them). All well and good with the frames restricting the values, however do I have to coded every single permutation. i.e. If field A and Field B are not null and fields C D E F are null, search etc, and then onto the next permutation.
The single instance of code I have is (caters for 3 fields only):-
Do While x <= numEntries
If Sheets("Data").Range("F" & x).Value = Me.CBSearchSupplierName And Sheets("Data").Range("G" & x).Value = Me.CBSearchSupplierProg And Sheets("Data").Range("H" & x).Value = Me.CBSearchSupplierProj Then
isFound = True
numFound = numFound + 1
End If
x = x + 1
Loop
'Create results array
If numFound > 0 Then
ReDim Preserve rcArray(1 To numFound, 1 To 2)
Else
ReDim Preserve rcArray(1 To 1, 1 To 2)
rcArray(1, 1) = "Not Found"
End If
x = 2
Do While x <= numEntries
If Sheets("Data").Range("F" & x).Value = Me.CBSearchSupplierName And Sheets("Data").Range("G" & x).Value = Me.CBSearchSupplierProg And Sheets("Data").Range("H" & x).Value = Me.CBSearchSupplierProj Then
rcArray(lrw, 1) = Sheets("Data").Range("A" & x).Value
rcArray(lrw, 2) = Sheets("Data").Range("F" & x).Value
lrw = lrw + 1
End If
x = x + 1
Loop
Any help would be appreciated and I know my explanation is convoluted.
Sean
I have created a UserForm for a dependency management system and within each record I want the user to be able to use the user form to search using 7 criteria however they can use more than one criteria at once.
For example, they can search on the Unique ID only, but they can also search on Dependency Supplier Name, Supplier Program and Supplier Project. Other fields are Dependency Receiver Name, Dependency Program and Dependency Project.
I am controlling the frames on the user form to only allow the user to search on the Unique ID only, the Supplier fields only (3 of them) or the Receiver fields (3 of them). All well and good with the frames restricting the values, however do I have to coded every single permutation. i.e. If field A and Field B are not null and fields C D E F are null, search etc, and then onto the next permutation.
The single instance of code I have is (caters for 3 fields only):-
Do While x <= numEntries
If Sheets("Data").Range("F" & x).Value = Me.CBSearchSupplierName And Sheets("Data").Range("G" & x).Value = Me.CBSearchSupplierProg And Sheets("Data").Range("H" & x).Value = Me.CBSearchSupplierProj Then
isFound = True
numFound = numFound + 1
End If
x = x + 1
Loop
'Create results array
If numFound > 0 Then
ReDim Preserve rcArray(1 To numFound, 1 To 2)
Else
ReDim Preserve rcArray(1 To 1, 1 To 2)
rcArray(1, 1) = "Not Found"
End If
x = 2
Do While x <= numEntries
If Sheets("Data").Range("F" & x).Value = Me.CBSearchSupplierName And Sheets("Data").Range("G" & x).Value = Me.CBSearchSupplierProg And Sheets("Data").Range("H" & x).Value = Me.CBSearchSupplierProj Then
rcArray(lrw, 1) = Sheets("Data").Range("A" & x).Value
rcArray(lrw, 2) = Sheets("Data").Range("F" & x).Value
lrw = lrw + 1
End If
x = x + 1
Loop
Any help would be appreciated and I know my explanation is convoluted.
Sean