Hi experts,
I'm new to VBA so please go easy. I used to post on the site as Holly_Associated but have had to change my user due to a change of job and so cannot upload an example of what I am doing. I shall try to explain below, without writing War & Peace!
I am using a public function to feed a variable string to a query. So far I have got:
This is something I have used from someone else and so I 'kind of' understand what I'm doing. The part that is highlighting as needing debugging is the red text.
The reason is that the instance of streetVar is not always a greater length than newFL. (I think!)
However, I only need to use newStreet as the true part of iif, in which instance all are longer. At least I think this is the problem. I realise I might need to use NZ but am not sure how. And can anyone explain why it is evaluating and giving errors for all records and not just when the iif criteria is true as I want it to?
Any help or pointers would be much appreciated, and I apologise if this is glaringly obvious!
If you need a better explanation please let me know. I usually include a little playDB but can't upload at the moment!
Thank you, Holly
I'm new to VBA so please go easy. I used to post on the site as Holly_Associated but have had to change my user due to a change of job and so cannot upload an example of what I am doing. I shall try to explain below, without writing War & Peace!
I am using a public function to feed a variable string to a query. So far I have got:
Code:
Public Function ClientStreetModule(firstLVar As Variant, streetVar As Variant, newFL As Variant) As String
Dim cslStr1 As String, newStreet As String
[COLOR=red]newStreet = Right(streetVar, Len(streetVar) - Len(newFL))[/COLOR]
cslStr1 = IIf(firstLVar = "Small Client A-M" Or firstLVar = "Small Client N-Z", newStreet, streetVar)
ClientStreetModule = cslStr1
End Function
The reason is that the instance of streetVar is not always a greater length than newFL. (I think!)
However, I only need to use newStreet as the true part of iif, in which instance all are longer. At least I think this is the problem. I realise I might need to use NZ but am not sure how. And can anyone explain why it is evaluating and giving errors for all records and not just when the iif criteria is true as I want it to?
Any help or pointers would be much appreciated, and I apologise if this is glaringly obvious!
If you need a better explanation please let me know. I usually include a little playDB but can't upload at the moment!
Thank you, Holly