Setting RowSource from Sub Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a sub form which I am trying to use to create a SQL statement which I
can apply to the main forms rowsource. How do I apply strSQL to the Main
Forms rowsource and then refresh main form?

Private Sub CmdFilter_Click()
Dim strSQL As String
Dim strSuppStatus As Long

If Me.fraSuppStatus.Value = 1 Then
strSuppStatus = 1
ElseIf Me.fraSuppStatus.Value = 2 Then
strSuppStatus = 2
Else
strSuppStatus = ""
End If

Debug.Print strSuppStatus

strSQL = "SELECT tblSuppliers.SupplierID, tblSuppliers.SupplierName,
tblSuppliers.Address1, tblSuppliers.Address2, tblSuppliers.City,
tblSuppliers.CountyID, tblSuppliers.Postcode, tblSuppliers.ContactName,
tblSuppliers.TelephoneNumber, tblSuppliers.FaxNumber,
tblSuppliers.EmailAddress, tblSuppliers.MobilePhone, tblSuppliers.Notes,
tblSuppliers.StatusID, tblSuppliers.CommodityID FROM tblSuppliers WHERE
tblSuppliers.StatusID=" & strSuppStatus & ";"

Forms!frmsuppliermenu.RowSource = strSQL

End Sub
 
Edgar said:
I have a sub form which I am trying to use to create a SQL statement which I
can apply to the main forms rowsource. How do I apply strSQL to the Main
Forms rowsource and then refresh main form?
[snip]

Forms do not have a RowSource property, that's for List and
combo boxes. You should use the RecordSource property.

Setting the RecordSource automatically requeries the form so
you don't need to do anything extra to refresh the form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Excel Export Filtered Form Data To Excel 0
Drowning in Loops 1
Paramater box pop up even if customer selected in combo box 1
HELP NEEDED WITH REPORT 1
Wildcard question 1
Blank Report 2
code not working 3
CODE HELP! 2

Back
Top