How do I fill in a text box from option group?

BarryMK

4 strings are enough
Local time
Today, 22:45
Joined
Oct 15, 2002
Messages
1,349
I have an option group on a form which returns values of 1 - 5 depending on the button selected. I would like to have a text box on the form called "cost" filled in when an option is selected. In this case if option 1 is checked the figure of £30 would be inserted into "cost" but if any of the remaining 4 options is selected £35 would be inserted.

I've tried adapting code I've used previously to fill in a text box from a check box but to no avail and I've trawled through many pages in the forums but found nothing so far. I'm in danger of losing the hair I've got left!
 
Code:
Private Sub YourFrame_AfterUpdate()

Select Case Me.YourFrame.Value

Case 1
Me.Cost = 30

Case 2
Me.Cost = 35

Case 3
Me.Cost = 35

Case 4
Me.Cost = 35

Case 4
Me.Cost = 35

Case Else

Exit Sub

End Select

End Sub

IMO
 
if me.frame = 1 then
me.cost = 30
else
me.cost = 35
endif

that seems to be sufficient

Regards

The Mailman
 
Or, in one line:

Code:
Me.Cost = IIf(Me.Frame = 1, 30, 35)
 
Thanks IMO but.........

I'm getting a method or data member not found and the frame name highlighted


Private Sub Form_AfterUpdate()
Select Case Me.Frame200.Value
Case 1 Me.cost = 30
Case 2 Me.cost = 35
Case 3 Me.cost = 35
Case 4 Me.cost = 35
Case 5 Me.cost = 35
Else: Exit Sub
End Select
End Sub
 
Because you're using the Forms AfterUpdate, you need to use the option group AfterUpdate

IMO
 
Thanks folks I've tried each method and still the frame name seems to be the problem, I must be doing something stupid but I dion't know what.
 
IMO the problem is I couldn't isolate the frame itself to add the event. I used the option group wizard.
 
Open the form in design view, right click the frame (not the Toggle buttons) and go to properties. Scroll down to AfterUpdate, select Event Procedure then click the "..." button to open the code window. Insert any one of the three pieces of code given there.

IMO
 
Yes I did work it out, thanks for everyone's help. I can't quite believe I was so thick that I never thought to click on the FRAME itself to get the properties dialog. I must have been having a senior moment. Blame it on the heatwave, pressure of work etc etc....hmmmm
 

Users who are viewing this thread

Back
Top Bottom