JamesMcS
Keyboard-Chair Interface
- Local time
- Today, 19:25
- Joined
- Sep 7, 2009
- Messages
- 1,819
Hi all, how's it going? Got an annoying one.... (aren't they all)
I've got a routine that looks like this:
	
	
	
		
It's supposed to bring back the maximum value for a given number of fields, but it's erroring out on the maxorg=flds(i).name line, saying object required (I know .Name isn't a valid member as the argument is a variant).
What I want to do is get whatever was entered as the argument, rather than the contents of the field. Make sense? Just for instance - I call the function thusly:
	
		
Org1 = 100
Org2 = 200
Org3 = 300
I'd like the function to return "Org3". But how???
Thanks in advance!
 I've got a routine that looks like this:
		Code:
	
	
	Public Function Max_Salesorg(ParamArray flds() As Variant) As Double
Dim i As Byte, MaxOrg As String, MaxVal As Double
MaxOrg = flds(1).Name
MaxVal = flds(1)
For i = LBound(flds) + 1 To UBound(flds)
    
    If Nz(flds(i), 0) > MaxVal Then
    
        MaxOrg = flds(i).Name
        MaxVal = flds(i)
    
    End If
Next
Max_Salesorg = MaxOrg
End FunctionIt's supposed to bring back the maximum value for a given number of fields, but it's erroring out on the maxorg=flds(i).name line, saying object required (I know .Name isn't a valid member as the argument is a variant).
What I want to do is get whatever was entered as the argument, rather than the contents of the field. Make sense? Just for instance - I call the function thusly:
		Code:
	
	
	Max_Salesorg(Org1, Org2, Org3)Org1 = 100
Org2 = 200
Org3 = 300
I'd like the function to return "Org3". But how???
Thanks in advance!
 
	 
 
		

 
 
		 
 
		 
 
		