Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

After update - If Like Else else

Question posted by: david bonsall (Newbie) on June 30th, 2008 10:24 PM
I have a field called [Client_number] and the value of that field can be deciphered into a location for that client.

Eg. SU[any letter]023[000-999] = UK
SA[anyletter]024[000-999] = Australia

....so SUR023023 = UK, whereas SUT024076 = Australia.

This is simplified as there are 30 possible locations.

I would like a field called [location] that returns the correct location. I tried the following in the AfterUpdate box for the [Client_number] field.

If [Client_number] Like "[SU]?[023]*" Then
[Location] = "UK"
ElseIf [Client_number] Like "[SA]?[024]*" Then
[Location] = "Australia"
End If

...but it doesn't work. It returns "UK" for either "Likes".

Any suggestions?

Thanks

David
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
ADezii's Avatar
ADezii
Expert
3,869 Posts
June 30th, 2008
11:49 PM
#2

Re: After update - If Like Else else
By using Brackets ([ ]) with the Like Operator, you were testing for any 'single character' in the Range, try:
Code: ( text )
  1. If [Client_number] Like "SU?023*" Then
  2.   [Location] = "UK"
  3. ElseIf [Client_number] Like "SA?024*" Then
  4.   [Location] = "Australia"
  5. Else
  6.   'whatever
  7. End If

Reply
david bonsall's Avatar
david bonsall
Newbie
3 Posts
July 1st, 2008
05:45 PM
#3

Re: After update - If Like Else else
Thanks a bunch,

It works a dream. Just one more thing. This code only works in the Form and I can't get it to work in Table format (there doesn't appear to be an afterupdate option in the table and I don't know how to input the code). I need it to work in table form because I plan to import a large amount of data from excel.

Any ideas?

Regards

David

Reply
missinglinq's Avatar
missinglinq
Moderator
2,350 Posts
July 1st, 2008
06:32 PM
#4

Re: After update - If Like Else else
As explained in your thread http://bytes.com/forum/thread817865.html fields in tables do not have events. You failed to mention, in your other thread, that your problem involves importing data into a table. Even if you were using a table, the AfterUpdate event wouldn't fire when the data was imported, as it only fires if data is physically entered into a textbox, not when data is entered thru code.

Perhaps if you explained exactly what it is you're trying to accomplish we could help you with a solution.

Linq ;0)>

Reply
NeoPa's Avatar
NeoPa
Administrator
10,449 Posts
July 3rd, 2008
04:10 PM
#5

Re: After update - If Like Else else
David, It's far easier to help you if you :
  1. Include all relevant information in your original question.
  2. Do not double post on the same issue.
Having been involved in setting up the rules for the site, I can confirm that that's exactly why the rules (http://bytes.com/forum/faq.php?faq=...ting_guidelines) were set up to include the above stipulations.

Reply
NeoPa's Avatar
NeoPa
Administrator
10,449 Posts
July 3rd, 2008
04:13 PM
#6

Re: After update - If Like Else else
As far as your problem is concerned, you may have to run an update query against a table (where the logic is stored) which updates the newly created records from your import.

Let us know (in here) if you would like help formulating this process.

Reply
Reply
Not the answer you were looking for? Post your question . . .
183,905 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top Microsoft Access / VBA Forum Contributors