Gary thanks for your help. I am trying to put the radio buttons in the
dataform view, It is in the Form Header in design mode, but is not showing up
when the datasheet is run. I checked the attributes and visible is turned on.
Also How would I pass the sql to a subform as this is an alternative method
I can use. ie I have a form with the subform displaying the datasheet.
thanks
I'm sorry Charlie...my bad.
I read "datasheet" and thought
"continuous form." If I ever needed
a "datasheet-like" form, I have always
designed a continuous form that "looked
like" a datasheet.
That way I *can* put controls in the form
header.
So...what to do....
1) If you want to put a datasheet
as a subform in a main form, you
want to know how to change the
recordsource of the subform:
When you add a subform (say "frmSubxxx")
to a main form (say "frmMain"), that subform
exists in a *subform control* which may or may
not have the same name as "frmSubxxx."
If it is the same name (check Properties of
your subform control), then the short answer
for code executed in the main form:
Forms!frmMain!frmSubxxx.Form.RecordSource = strSQL
or
Me!frmSubxxx.Form.RecordSource = strSQL
the "Forms!frmMain!frmSubxxx"
(or "Me!frmSubxxx") gets us to
the subform *control*.
Within that control is a Form (the "actual subform")
which has a RecordSource.
Another way of looking at it
===============
Dim ctl As Control
Dim frm As Form
Set ctl = Me!frmSubxxx
Set frm = ctl.Form
frm.RecordSource = strSQL
=================
So you checked the Properties
of your subform you put on your
main form and you see:
Name : frmSubxxx
Source Object: frmSubxxx
using whatever is in *Name*
(of control) line, your event
on the main form might look like
(aircode, untested)
Private Sub optSortBy_AfterUpdate()
On Error GoTo Err_optSortBy_AfterUpdate
Dim strSQL As String
Dim strOrderBy As String
Dim intPos As Integer
Dim ctl As Access.Control
Dim frm As Access.Form
'use Name of subform control here!
Set ctl = Me!frmSubxxx
Set frm = ctl.Form
strSQL = "SELECT I.[Sample Number], " _
& "I.[Stockpile Number], S.[Last Update], " _
& "S.[Minus Size], S.[Plus Size], S.Result " _
& "FROM [Inbound Samples] AS I " _
& "INNER JOIN " _
& "[Sizing Samples] AS S " _
& "ON I.[Sample Number] = S.[Sample Number] "
If Me!optSortBy = 1 Then
strOrderBy= "ORDER BY I.[Sample Number], S.[Plus Size];"
Else
strOrderBy= "ORDER BY S.[Plus Size], I.[Sample Number];"
End If
strSQL = strSQL & strOrderBy
'update recordsource of subform
frm.RecordSource = strSQL
frm.Requery
Exit_optSortBy_AfterUpdate:
Set ctl = Nothing
Set frm = Nothing
Exit Sub
Err_optSortBy_AfterUpdate:
MsgBox Err.Description
Resume Exit_optSortBy_AfterUpdate
End Sub
2) there are advantages to using a
continuous form that looks "like"
a datasheet. Here be a few I can
think up at the moment:
a) you can use combobox controls
for some of the fields, so users can
only change a field value to "exact"
value (no mistypes)
b) your field controls have events like
"After_Update" where you can put
some code
c) you get a form header where, at
the least, you can put a close-form
command button so you can close
the form "gracefully."
There are probably more, but....
good luck,
gary
"Charlie"wrote:
> Gary thanks for your help. I am trying to put the radio buttons in the
> dataform view, It is in the Form Header in design mode, but is not showing
[quoted text clipped - 5 lines]
> method
> I can use. ie I have a form with the subform displaying the datasheet.