My first post was was incorrect. The subform is based on a recordsource clone.
This is the code behind the find button i created.
Private Sub Command36_Click()
Dim MySQL As String, MyCriteria As String, MyRecordSource As String
Dim ArgCount As Integer
' Initialize SELECT statement.
MySQL = "SELECT * FROM [Maintable] WHERE "
' Use values entered in text boxes in form header to create criteria
for WHERE clause.
'text box name on form 'Field name in Table 'blank info '
number of times run Addt
AddToWhere [Find1], "[ItemNumber]", MyCriteria, ArgCount
AddToWhere [Find2], "[Sub]", MyCriteria, ArgCount
' If no criterion specifed, return all records.
If MyCriteria = "" Then
MyCriteria = "True"
End If
' Create SELECT statement.
MyRecordSource = MySQL & MyCriteria
' Optional Order By clause
If Me![Find1] <> "" Then
MyRecordSource = MySQL & MyCriteria & " ORDER BY [ItemNumber]"
ElseIf Me![Find2] <> "" Then
MyRecordSource = MySQL & MyCriteria & " ORDER BY [Sub]"
Else
MyRecordSource = MySQL & MyCriteria & " ORDER BY [ItemNumber]"
End If
' set record source to Subform
Me![MaintableSubform].Form.RecordSource = MyRecordSource
Exit_VIEW_Click:
Exit Sub
Err_VIEW_Click:
MsgBox Error$
Resume Exit_VIEW_Click
End Sub
Thank you for your response. Im just unsure of what the recordsource should
actually be.
Duane Hookom said:
How are you filtering the subform? Have you tried creating a report based on
the same record source as your subform? Can you get that much to work?
--
Duane Hookom
Microsoft Access MVP
:
Let me just say I am very new to access.I am working with Access 2007.My
situation is this,i have a main form with 2 unbound text boxes to search a
query based on my main table.The results of this search are then displayed in
a subform in datasheet view.I am trying to create a report button on the main
form based on search results.If i make the report on the subform i am getting
labels only no data results.I would appreciate any assistance provided.
Thanks