What error do you get? Does it highlight a line of code as generating the
error?
Doing this in the Load event of the form would mean that the value in the
option group is stored in the table. It also indicates that both the option
group and the textbox are on the same form. You then assign the text value
to the textbox txtShowStatus. Is this textbox also bound to the table? If
so, why? You have the information already stored by storing the option group
value. Instead of using this code, try making the textbox a calculated
control instead.
Example for the control source for txtShowStatus:
=Choose(Nz([OptionValue],0) + 1, "Unselected", "Potential", "Active",
"Seen", "Sold")
As far as the error goes, I suspect it is a timing issue with the form just
loading. The value should be available in the form's load event, but I'm
guessing it isn't. Also, if you move to another record, doing this in code
will require this code to be in the form's Current event also so that the
text will change to match the value in the next record. If you have the code
in the Current event, that event also fires when the form loads the first
record as the form loads, making the code in the Load event unnecessary.
Making the textbox a calculated control will make the code to fill in the
textbox in both events unnecessary.
--
Wayne Morgan
MS Access MVP
Norwedsh said:
Works fine in Access 2003, nada 2007 beta
Private Sub Form_Load()
Dim intSeller As Integer
intSeller = Nz(Me.OptionValue.Value, 0)
Select Case intSeller 'Dispalys house status
Case 0 'Determined by numeric values
txtShowStatus = "Unselected"
Exit Sub 'determined by the option group
Case 1
txtShowStatus = "Potential"
Case 2
txtShowStatus = "Active"
Case 3
txtShowStatus = "Seen"
Case 4
txtShowStatus = "Sold"
End Select
End Sub