Connecting Tech Pros Worldwide Forums | Help | Site Map

After update - If Like Else else

Newbie
 
Join Date: Jun 2008
Posts: 3
#1: Jun 30 '08
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

ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,219
#2: Jul 1 '08

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:
Expand|Select|Wrap|Line Numbers
  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
Newbie
 
Join Date: Jun 2008
Posts: 3
#3: Jul 1 '08

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
missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,000
#4: Jul 1 '08

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)>
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#5: Jul 3 '08

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=t...ing_guidelines) were set up to include the above stipulations.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#6: Jul 3 '08

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