UDF not working perfect in access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I create one UDF and it working perfect in access form but one I try to used
in access query it give me this message (run time error ‘424’: object
requiredâ€, so what problem if you can help in this matter
Thanks
Yusuf
 
Can you post your code so we can see what might be wrong? It is very hard to
deduce anything about a specific error like this without the code that is
causing it.
 
Function GetSort(rng As Variant) As Variant


ElseIf rng.Value Like "*ABN-AMRO*" Then
GetSort = "ABN-AMRO BANK"

ElseIf rng.Value Like "*CITI BANK*" Then
GetSort = "CITI BANK"


ElseIf rng.Value Like "H.S.B.C*" Then
GetSort = "H.S.B.C.- BANK"


Else
GetSort = "CASH"


End If


End Function
 
Is that the whole thing? You can't start an IF...Then...Else statement off
with an ElseIf.
 
yusuf said:
Function GetSort(rng As Variant) As Variant

ElseIf rng.Value Like "*ABN-AMRO*" Then
GetSort = "ABN-AMRO BANK"

ElseIf rng.Value Like "*CITI BANK*" Then
GetSort = "CITI BANK"


ElseIf rng.Value Like "H.S.B.C*" Then
GetSort = "H.S.B.C.- BANK"


In addition to the issue Bob identified, you can not use the
Value property of an argument. It might work in your form
because Access magically figures out that you are passing a
text box control in a variant instead of the text box's
value, but Access doesn't appear to be able to do that for a
field in a query.

I think all you need to do is get rid of the .Value and just
use:

ElseIf rng Like "*CITI BANK*" Then
 
Sorry while copying I missed the first two lines , actually it is starting
with IF, and Mr. Marshall Answer it is right and working perfectly.
Thanks to all
 
Back
Top