R
Raymond
I am having a problem quering two subforms from 3 combo boxesHi, Basically I
have a form that contains two sub forms and each sub form has its own
individual query. On the main form I have 3 unbound combo boxes (Item #, date
received and date shipped) that I have the user select and depending on their
selection the two sub forms should display the matching data. The first sub
form contains the "received" information based a query and the second sub
form contains the "shipped" information based on a different query. I have
linked the sub forms using the Link Master/Child fields dialogue box. For
example, if the user selects Item # 101 and received date 1/1/10 and shipped
date 1/31/10. I would like all the records for item 101 that were received on
or after 1/1/10 and shipped on or before 1/31/10 to appear. But all I get is
a compile error. The Main form is call "Inventory" and the two sub forms are
called "Received Information" and "Shipped Information". Any help would be
greatly appreciated. I have the following code but I am getting a run time
2465 error on the second to the last line (Me.[qry Received
Information].Form.RecordSource = strSQLReceived).
Private Sub Command61_Click()
Dim strSQLReceived As String
Dim strSQLShipped As String
Dim strWhere As String
strWhere = " Where 1=1 "
strSQLReceived = "SELECT * FROM [qry Received Information]"
strSQLShipped = "SELECT * FROM [qry Shipped Information]"
If Not IsNull(Me.cboItemNum) Then
strWhere = strWhere & " AND ItemCode = " & _
Me.cboItemNum & " "
End If
If Not IsNull(Me.cboRecvd) Then
strWhere = strWhere & " AND [Date Received] >= #" & _
Me.cboRecvd & "# "
End If
If Not IsNull(Me.cboShipped) Then
strWhere = strWhere & " AND [Date Shipped] <= #" & _
Me.cboShipped & "# "
End If
strSQLReceived = strSQL & strWhere & " ORDER BY Receiving.[Date Received];"
strSQLShipped = strSQL & strWhere & " ORDER BY Shipping.[Date Shipped];"
Me.[qry Received Information].Form.RecordSource = strSQLReceived
Me.[qry Shipped Information].Form.RecordSource = strSQLShipped
End Sub
have a form that contains two sub forms and each sub form has its own
individual query. On the main form I have 3 unbound combo boxes (Item #, date
received and date shipped) that I have the user select and depending on their
selection the two sub forms should display the matching data. The first sub
form contains the "received" information based a query and the second sub
form contains the "shipped" information based on a different query. I have
linked the sub forms using the Link Master/Child fields dialogue box. For
example, if the user selects Item # 101 and received date 1/1/10 and shipped
date 1/31/10. I would like all the records for item 101 that were received on
or after 1/1/10 and shipped on or before 1/31/10 to appear. But all I get is
a compile error. The Main form is call "Inventory" and the two sub forms are
called "Received Information" and "Shipped Information". Any help would be
greatly appreciated. I have the following code but I am getting a run time
2465 error on the second to the last line (Me.[qry Received
Information].Form.RecordSource = strSQLReceived).
Private Sub Command61_Click()
Dim strSQLReceived As String
Dim strSQLShipped As String
Dim strWhere As String
strWhere = " Where 1=1 "
strSQLReceived = "SELECT * FROM [qry Received Information]"
strSQLShipped = "SELECT * FROM [qry Shipped Information]"
If Not IsNull(Me.cboItemNum) Then
strWhere = strWhere & " AND ItemCode = " & _
Me.cboItemNum & " "
End If
If Not IsNull(Me.cboRecvd) Then
strWhere = strWhere & " AND [Date Received] >= #" & _
Me.cboRecvd & "# "
End If
If Not IsNull(Me.cboShipped) Then
strWhere = strWhere & " AND [Date Shipped] <= #" & _
Me.cboShipped & "# "
End If
strSQLReceived = strSQL & strWhere & " ORDER BY Receiving.[Date Received];"
strSQLShipped = strSQL & strWhere & " ORDER BY Shipping.[Date Shipped];"
Me.[qry Received Information].Form.RecordSource = strSQLReceived
Me.[qry Shipped Information].Form.RecordSource = strSQLShipped
End Sub