updating field based on other field - On current doesn't do it?

  • Thread starter Thread starter efandango
  • Start date Start date
E

efandango

I have a number of records/fields on a continous subform that I want to set
automatically depending on the value in another field.

I have tried to get the code to work with the 'On Current' event for the
form, but the field only updates after I click on each record entry.

How can I make it so that when I open the form, ALL the records update
automatically without having to go down the list and click each one?

my code: (On Current)

If Me.OrderSeq = "1" Then Me.Alpha_Buttons = "X1"
If Me.OrderSeq = "2" Then Me.Alpha_Buttons = "A"
If Me.OrderSeq = "3" Then Me.Alpha_Buttons = "B"
If Me.OrderSeq = "4" Then Me.Alpha_Buttons = "C"
If Me.OrderSeq = "5" Then Me.Alpha_Buttons = "D"
If Me.OrderSeq = "6" Then Me.Alpha_Buttons = "E"
If Me.OrderSeq = "7" Then Me.Alpha_Buttons = "F"
If Me.OrderSeq = "8" Then Me.Alpha_Buttons = "G"
If Me.OrderSeq = "9" Then Me.Alpha_Buttons = "H"
If Me.OrderSeq = "10" Then Me.Alpha_Buttons = "X2"
If Me.OrderSeq = "11" Then Me.Alpha_Buttons = "I"
If Me.OrderSeq = "12" Then Me.Alpha_Buttons = "J"
If Me.OrderSeq = "13" Then Me.Alpha_Buttons = "K"
If Me.OrderSeq = "14" Then Me.Alpha_Buttons = "L"
If Me.OrderSeq = "15" Then Me.Alpha_Buttons = "M"
If Me.OrderSeq = "16" Then Me.Alpha_Buttons = "N"
If Me.OrderSeq = "17" Then Me.Alpha_Buttons = "O"
If Me.OrderSeq = "18" Then Me.Alpha_Buttons = "P"
 
efandango said:
I have a number of records/fields on a continous subform that I want
to set automatically depending on the value in another field.

I have tried to get the code to work with the 'On Current' event for
the form, but the field only updates after I click on each record
entry.

How can I make it so that when I open the form, ALL the records update
automatically without having to go down the list and click each one?

my code: (On Current)

If Me.OrderSeq = "1" Then Me.Alpha_Buttons = "X1"
If Me.OrderSeq = "2" Then Me.Alpha_Buttons = "A"
If Me.OrderSeq = "3" Then Me.Alpha_Buttons = "B"
If Me.OrderSeq = "4" Then Me.Alpha_Buttons = "C"
If Me.OrderSeq = "5" Then Me.Alpha_Buttons = "D"
If Me.OrderSeq = "6" Then Me.Alpha_Buttons = "E"
If Me.OrderSeq = "7" Then Me.Alpha_Buttons = "F"
If Me.OrderSeq = "8" Then Me.Alpha_Buttons = "G"
If Me.OrderSeq = "9" Then Me.Alpha_Buttons = "H"
If Me.OrderSeq = "10" Then Me.Alpha_Buttons = "X2"
If Me.OrderSeq = "11" Then Me.Alpha_Buttons = "I"
If Me.OrderSeq = "12" Then Me.Alpha_Buttons = "J"
If Me.OrderSeq = "13" Then Me.Alpha_Buttons = "K"
If Me.OrderSeq = "14" Then Me.Alpha_Buttons = "L"
If Me.OrderSeq = "15" Then Me.Alpha_Buttons = "M"
If Me.OrderSeq = "16" Then Me.Alpha_Buttons = "N"
If Me.OrderSeq = "17" Then Me.Alpha_Buttons = "O"
If Me.OrderSeq = "18" Then Me.Alpha_Buttons = "P"

Alpha_Buttons should not be a field in your table. It should be calculated
value based on an expression. If your Alpha_Buttons TextBox had a
ControlSource of...

=Choose(OrderSeq, "X1", "A", "B", etc..)

....it would display what you want on each row. Note that this value would
not be transferred to your table, but as stated, it doesn't belong there
anyway.
 
Rick,

Firstly, a big thanks...

I always knew that I need not have the 'Alpha_Buttons' as a table sourced
field, but just didn't know how to work on so many variables in one text box.

That ControlSource code really was quite magical!, it works perfectly.

If you have the time; care to explain what is going on with the codeline?
 
efandango said:
Rick,

Firstly, a big thanks...

I always knew that I need not have the 'Alpha_Buttons' as a table
sourced field, but just didn't know how to work on so many variables
in one text box.

That ControlSource code really was quite magical!, it works perfectly.

If you have the time; care to explain what is going on with the
codeline?

I suggest reading the help file topic on the Choose() function for full
details.

Basically if the the first argument's value is 1 then the function returns
the value of the second argument. If the first argument's value is 2 then
you get the third argument's value returned.
 
Back
Top