> Hi,
> I was wondering if any one might know a quick solution to my problem:
[quoted text clipped - 19 lines]
> Thanks,
> GLT.
No, there's no built-in function for that. The option buttons can't
really be part of an option group, either, because an option group can
only have one value. So you're stuck loading and unloading records from
the table of days yourself. It's not unlike the code that is needed to
store multiple selected options from a multiselect list box.
You'll need code in the form's Current event to get the initial values
of all the "day" options, and code in the AfterUpdate event of each
option button. The following is just air code, but I'm thinking you
need something like this:
'----- start of example "air code" -----
Function UpdateDay()
' This is a helper function to add or remove a
' record from tblMainDays depending on the
' value and name of the option-button control
' that is passed as an argument. We require
' that the name of the control end with the
' day number, 1 to 7, for which the update
' is required.
Dim strSQL As String
With Me.ActiveControl
If .Value = True Then
strSQL = _
"INSERT INTO tblMainDays(MainID, DayNo) " & _
"VALUES(" & Me.MainID & ", " & _
Right(l.Name, 1) & ")"
Else
strSQL = _
"DELETE * FROM tblMainDays " & _
"WHERE MainID = " & Me.MainID & _
" AND DayNo = " & Right(.Name, 1)
End If
End With
CurrentDb.Execute strSQL, dbFailOnError
End Sub
Private Sub Form_Current()
Dim rs As DAO.Recordset
Dim intDay As Integer
Set rs = CurrentDb.OpenRecordset( _
"SELECT * FROM tblMainDays " & _
"WHERE MainID=" & Me.MainID)
' Clear all day options.
For intDay = 1 to 7
Me.Controls("optDay" & intDay) = False
Next intDay
' Set those options for which there are records in rs.
With rs
Do Until .EOF
Me.Controls("optDay" & !DayNo) = True
.MoveNext
Loop
.Close
End With
Set rs = Nothing
End Sub
'----- end of example "air code" -----
Then you can set the AfterUpdate event property (on the Event tab of the
property sheet) of each of the 7 options controls named optDay1,
optDay2, ... optDay7 to this function expression:
=UpdateDay()
I think that should do it.

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
GLT - 23 Jan 2005 15:45 GMT
Thanks Dirk,
I have implemented what you said and I have it working.
There was a bug in one line (1st strSQL = ststement) is:
Right(l.Name, 1) & ")"
Should be just .Name:
Right(.Name, 1) & ")"
(just for anyone else out there who wants to use this.)
Thanks,
GLT
> > Hi,
> > I was wondering if any one might know a quick solution to my problem:
[quoted text clipped - 99 lines]
>
> I think that should do it.
Dirk Goldgar - 23 Jan 2005 16:23 GMT
> Thanks Dirk,
>
[quoted text clipped - 9 lines]
>
> (just for anyone else out there who wants to use this.)
Sorry about that. I had originally written it slightly differently,
using a Control object named "ctl", and then I changed my mind and
deleted (I thought) all the occurrences of "ctl". I'm glad you spotted
and fixed the problem.

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)