Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update a combo box from a value in a text box

Status
Not open for further replies.

juliesmomma

Technical User
Jun 3, 2002
36
0
0
US
Hi All!
What I am trying to accomplish is updating a combobox with a value that is in a text box.

The text box [Points] totals points from a survey for Cardiovascular Risk. If the number is >39 I want the combobox [Risk] automatically populated with &quot;High&quot;. If [Points] is between 20-39 I want [Risk] to be &quot;Medium&quot;. If [Points] is <20 then I want [Risk] to be &quot;Low&quot;.

I have tried putting code in the change event and the afterupdate event. I've tried using a Select Case statement and a multiway IF statement. I just can't seem to get it to work.

Any help would be appreciated.
 
Select Case Val(points)
Case Is > 39
risk = &quot;High&quot;
Case 20 To 39
risk = &quot;Medium&quot;
Case Is < 20
risk = &quot;Low&quot;
End Select

and this in the afterupdate of the textbox &quot;What a wonderfull world&quot; - Louis armstrong
 
chrissie1,
I tried your code in the afterupdate event of the textbox [Points] but it still didn't work. Could it be that my form is based on a query that figures the total for the field [Points]? I'm grasping at straws.

Thanks!
 
ah try setting this code in the on current of the form that should work better &quot;What a wonderfull world&quot; - Louis armstrong
 
Ok that works but it doesn't update the field unless I exit the form or go to another record and then go back. Also, it won't let me do a new record without the message &quot;Invalid use of null&quot; because the value in [Points] hasn't been figured yet.

You have been very helpful! Thanks for your patience....
 
put this in the form load

call form_current

and change the code as follows
if not isnull(points) then
Select Case Val(points)
Case Is > 39
risk = &quot;High&quot;
Case 20 To 39
risk = &quot;Medium&quot;
Case Is < 20
risk = &quot;Low&quot;
End Select
endif &quot;What a wonderfull world&quot; - Louis armstrong
 
That fixed the Null problem but I still would like it to update [Risk] while they are on the same record. It defaults &quot;Low&quot; in the [Risk]. They have the option of printing the form (report). If it doesn't update while they are on that record then it will have the wrong risk rating on it. I tried adding a refresh method to the form but it still isn't updating immediately.
 
is this when you have a new record

then try this in the afterinsert of the form

me.requery
call form_current &quot;What a wonderfull world&quot; - Louis armstrong
 
It still isn't doing it immediately. It's not when it's a new record. I want it to update in the current record.

Thanks for your help. Maybe it's just not possible.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top