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

How can I group an Option Button on a Continuous Form?

Status
Not open for further replies.

konacq

Technical User
Nov 10, 2004
8
CA
I have an option button on a continuous subform bound to a field called 'Default'. The subform shows a subset of records based on a SELECT statement using criteria derrived from fields on the master form. The idea is that one (and only one) record within the set of records returned from the SQL SELECT command will have a value of TRUE assigned to its Default option button. In effect, I want to create an option group consisting of a single option button spanned across multiple records on the subform.

Does anyone have any ideas?
 
Use the afterupdate event procedure of the option button.

You need some code like this:

Private Sub myyesno_AfterUpdate()
Me.Dirty = False 'must save current record first
Dim strsql
strsql = "Update (select * from mytable) as A set myyesno = false where mykeyfield <> " & Me.mykeyfieldtextbox
CurrentDb.Execute strsql, dbFailOnError

End Sub

This updates the yes/no field in the form's recordsource (expressed as a query) for every record except for the current record.



 
lupins46:

Thanks for the response. Using a JOIN I can select the relevant fields instead of '*'.

Konacq
 
As I was trying to say, the '(select * from mytable)' part of the query should be the recordsource of your form. If the recordsource is based on Joined tables then fine, as long as the form/query are updateable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top