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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default Value of Option Groups

Status
Not open for further replies.

MsMope

IS-IT--Management
Sep 3, 2003
83
0
0
US
Good afternoon,
I want to update my account table delivery value based on what is choosen in teh option group, but at load time I want the value to equal what is currently stored in the account table, how do I do this? I tried to set the default value of the frmDelivery = tblAccountProp.Delivery_Value, but the form loads with no selection specified.

Thanks,
 
All you have to do is bind the option group control to the field in the record source. You do that by setting its Control Source property.

If you've done that and nothing is selected as you move from record to record, it can only be because the value in the table doesn't match the Option Value property of any option button control in the group.

The Default Value doesn't work because it only applies to new records.

What is 'frmDelivery'? Its prefix suggests that it is a form, not an Option Group control.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
I have verified that the recordsource values match that of the option group, I have set the controlSource = to the field in the table, but when the form loads, I am unable to click on any of the option group buttons, and nothing is selected. any suggestions?
 
as an add-on to my last post, when the form is loaded and I attempt to click on the option buttons I recieve the following message on the bottom of the form:
Control cannot be edited; it is bound to expression 'user_tblAccountProp.Delivery_Value
 
SO I went back into the controlSource for the option group and built the following
[tbl_userAccountProp]![Delivery_Value]

there is no (=) in front, and I recieve the same message as above, with one exception
Control cannot be edited; it is bound to an unknown field [user_tblAccountProp]![Delivery_Value]

Y???
 
FYI~ I have corrected this issue, I reviewed the underlying query and it did not contain the field I was trying to reference therefore giving me the error.

 
I think you need to look at the OptionValue property of each option button, and not just the ControlSource of the Option Group. You need to set the OptionValue of an Option Button to equal the value of the field, using the On Current

For Example.. an Option Group with its ControlSource set to Delivery_Value and containing 2 option buttons (opt1 and opt2)

Me.opt1.OptionValue = Me!Delivery_Value
Me.opt2.OptionValue = Me!Delivery_Value * 1.1
Me.lblOpt1.Caption = Me!Delivery_Value
Me.lblOpt2.Caption = Me!Deliver_Value * 1.1

HTH
PaulF
 
If I need to reference each button within the group, then what is the advantage of using the group? Isn't that what the .value property is there for??

anyway, i have more issues with this, imagine that. Now I recieve the cannot edit error that I have read many posts on, the timestamp fix that is listed on Microsoft website did not help. I also tried to bind the value to a query, that also did not work, when I attempt to bind to the query, i recieve an error" cannot edit, the control is bound to an unknown expression" so I am stuck.

All I want to do is have the option button selected that matches the value in the table, value 1,2, or 3. It can't be that hard
 
what are the values in the table, 1,2,3 which match the OptionValue propery of the option buttons, or some other value?
If they are 1,2,3 then you should be able to use the ControlSource (make sure the value is numeric, not string or text). If it is some other value then you should be able to use the Form's On Current event and code to change the value of the option group.

PaulF
 
Yes the values are 1,2,3, but if I use the control source then I cannot change the values by clicking on different buttons, that is when I get the above listed error.

So this is what I put in the onCurrent, which also didn't work
Code:
Private Sub Form_Current()
Dim DelValueDefault As String
Dim strSQL As String
Dim db As Database, rs As Recordset
DelValueDefault = "api_del_Val_Default"
DoCmd.OpenQuery DelValueDefault
strSQL = "SELECT Delivery_Value FROM user_tblJobProp " & _
         "where user_tblJobProp.[ID]= '" & is_modItem_GetCurrentID() & "'"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
frmDelivery.Value = rs.Fields("Delivery_Value")
         
    LockFields
    If IsNull(ctlTruss_Price) Or ctlTruss_Price = " " Then
        ctlTruss_Price = 0
    End If
    If IsNull(ctlHanger_Price) Or ctlHanger_Price = " " Then
        ctlHanger_Price = 0
    End If
    If IsNull(ctlEngLum_Price) Or ctlEngLum_Price = " " Then
        ctlEngLum_Price = 0
    End If
    If IsNull(ctlstock_Price) Or ctlstock_Price = " " Then
        ctlstock_Price = 0
    End If
    Me.Refresh
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top