Connecting Tech Pros Worldwide Help | Site Map

Unbound to bound

Newbie
 
Join Date: Sep 2009
Posts: 4
#1: Sep 1 '09
I store a calculation in an unbound field. Based on this value another value must be stored in a bound field eg <100 = A; <200 = B etc.but it only updates the bound field once I've clicked on it. Any ideas what I'm doing wrong?
Member
 
Join Date: Mar 2009
Location: Conroe, TX
Posts: 57
#2: Sep 1 '09

re: Unbound to bound


Can you post the code that is setting the value of the bound field.
Newbie
 
Join Date: Sep 2009
Posts: 4
#3: Sep 2 '09

re: Unbound to bound


Expand|Select|Wrap|Line Numbers
  1. If Me.Text48.Value > 13060694016# Then
  2.   Me.OverallMaintenanceImportance.Value = "A"
  3. End If
  4. If Me.Text48.Value > 11612804 Or Me.Text48 < 13060694016# Or Me.Text48 = 13060694016# Then
  5.   Me.OverallMaintenanceImportance.Value = "B"
  6. End If
  7. If Me.Text48.Value > 10161616 Or Me.Text48 < 11612804 Or Me.Text48 = 11612804 Then
  8.   Me.OverallMaintenanceImportance.Value = "C"
  9. End If
  10. If Me.Text48.Value > 8710428 Or Me.Text48 < 10161616 Or Me.Text48 = 10161616 Then
  11.   Me.OverallMaintenanceImportance.Value = "D"
  12. End If
  13. If Me.Text48.Value > 7259240 Or Me.Text48 < 8710428 Or Me.Text48 = 8710428 Then
  14.   Me.OverallMaintenanceImportance.Value = "E"
  15. End If
  16. If Me.Text48.Value > 5804752 Or Me.Text48 < 7259240 Or Me.Text48 = 7259240 Then
  17.   Me.OverallMaintenanceImportance.Value = "F"
  18. End If
  19. If Me.Text48.Value > 4553564 Or Me.Text48 < 5804752 Or Me.Text48 = 5804752 Then
  20.   Me.OverallMaintenanceImportance.Value = "G"
  21. End If
  22. If Me.Text48.Value > 2902376 Or Me.Text48 < 4553564 Or Me.Text48 = 4553564 Then
  23.   Me.OverallMaintenanceImportance.Value = "H"
  24. End If
  25. If Me.Text48.Value > 1451189 Or Me.Text48 < 2902376 Or Me.Text48 = 2902376 Then
  26.   Me.OverallMaintenanceImportance.Value = "I"
  27. End If
  28. If Me.Text48.Value < 1451189 Or Me.Text48 = 1451189 Then
  29.   Me.OverallMaintenanceImportance.Value = "J"
  30. End If
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,074
#4: Sep 3 '09

re: Unbound to bound


I think you might be interested in using a switch.....
Newbie
 
Join Date: Sep 2009
Posts: 4
#5: Sep 3 '09

re: Unbound to bound


Thanks a million. I have used the If ElseIf command and it works like a charm. Much appreciated
FishVal's Avatar
Expert
 
Join Date: Jun 2007
Location: Israel
Posts: 2,584
#6: Sep 3 '09

re: Unbound to bound


Impressed ... very impressed.

Would you like to read the following?
Grouping Query Range

P.S. BTW, does it really work?
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,690
#7: Sep 3 '09

re: Unbound to bound


Am I too late to the party?

I strongly suggest using a Select Case construct for this code. Neater & faster of execution than ElseIf .

BTW, you don't include the code which would have indicated where your existing code was running. I suggest if you put some code in the AfterUpdate event procedure of your unbound control, that it will behave as you hope.

Good luck and Welcome to Bytes!
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,074
#8: Sep 3 '09

re: Unbound to bound


Thanks NeoPa!
I didn't know if it was called a Switch or a Select Case....just grabbed the first reasonable thing I saw that google showed came up with.

:)

-Frinny
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,074
#9: Sep 3 '09

re: Unbound to bound


Is my previous link even relevant?

It's weird but the switch function looks like it does the same sort of thing as a Select Case. The worst part of my confusion is that switch is the C++/C# equivalent to a select case....when I tried to google "access" and "select" I kept coming across SQL references so I changed the search to switch and tada some random function that I thought was relevant (but now I'm wondering about).

Just curious: do Access developers ever use that switch function I found googling?
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,690
#10: Sep 3 '09

re: Unbound to bound


Quote:

Originally Posted by Frinavale View Post

Just curious: do Access developers ever use that switch function I found googling?

Yes, but not much.

I guess you were trawling for some questions to answer & found Access huh :D

The Switch() is a natural find for a C/C++ developer. I went there myself some while back. In effect though, it is more similar to multiple ElseIfs. The Select Case is much more similar to the C Switch statement than Switch() is. In the Switch() function the whole comparison is evaluated for all of the comparisons, regardless of where the first true result is found. With Select Case, however, the left side is evaluated only the once, and the case statements are compared with it as they are reached. Once a true result is found no further Case statements are reached.

@Frinny Call me if you're online now.
FishVal's Avatar
Expert
 
Join Date: Jun 2007
Location: Israel
Posts: 2,584
#11: Sep 3 '09

re: Unbound to bound


Did anybody notice that actually all but the first and the last conditions always evaluate to True?

P.S. Array/Loop or, in DB application, Table/SQL could do this simple lookup efficiently and flexibly while Switch and If <removed as per site rules>. :P
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,074
#12: Sep 4 '09

re: Unbound to bound


Quote:

Originally Posted by NeoPa View Post

Yes, but not much.

I guess you were trawling for some questions to answer & found Access huh :D

Not quite. Was looking to bump this question because it was moderated for some reason....thought I could answer it. Obviously didn't do a very good job of it though :P

Quote:

Originally Posted by NeoPa View Post

@Frinny Call me if you're online now.

Think I missed ya.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,690
#13: Sep 4 '09

re: Unbound to bound


Quote:

Originally Posted by Frinavale View Post

Obviously didn't do a very good job of it though :P

It was a decent stab even for an Access person.

It was a pleasant surprise to have you visit this neck of the woods. Don't be put off.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,690
#14: Sep 4 '09

re: Unbound to bound


Quote:

Originally Posted by FishVal View Post

Did anybody notice that actually all but the first and the last conditions always evaluate to True?

I didn't :(

I expect the intended logic is obvious enough in this case though.
Quote:

Originally Posted by FishVal View Post

P.S. Array/Loop or, in DB application, Table/SQL could do this simple lookup efficiently and flexibly while Switch and If <removed as per site rules>. :P

Good call. I generally use a table only if the number of items is enough to make it worth the overhead (development rather than time or space). I set the threshold lower for exact match lists. This task may well fit into this category.

Please explain what was removed. I think I'm probably having a dumb moment, but I'm missing the joke here :S
Member
 
Join Date: Mar 2009
Location: Conroe, TX
Posts: 57
#15: Sep 4 '09

re: Unbound to bound


Does anybody else think that these should be And... not Or.
Expand|Select|Wrap|Line Numbers
  1. If Me.Text48.Value > 11612804 And Me.Text48 <= 13060694016#  
  2. Me.OverallMaintenanceImportance.Value = "B" 
I removed the last expression and put the <= to do both Suziem
Newbie
 
Join Date: Sep 2009
Posts: 4
#16: Sep 4 '09

re: Unbound to bound


Agreed but rusted. Haven't done programming for a while. I also changed it to elseif and it worked like a charm
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,690
#17: Sep 4 '09

re: Unbound to bound


Quote:

Originally Posted by kstevens View Post

Does anybody else think that these should be And... not Or.

That's basically what Fish was saying in post #11 ;)

You're absolutely right of course K.
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,074
#18: Sep 4 '09

re: Unbound to bound


I still think it looks messy and could be much nicer, cleaner, faster code if it was a Select Case :)


(PS I checked out Access 2007 last night... all I can say is wow, there's more to it than I thought)
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,690
#19: Sep 4 '09

re: Unbound to bound


Quote:

Originally Posted by Frinavale View Post

I still think it looks messy and could be much nicer, cleaner, faster code if it was a Select Case :)

You're absolutely right of course Frinny, but I suspect the OP is a bit nervous about doing anything new having only recently returned to coding.
Reply