Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error 13,really need help

Status
Not open for further replies.

rry2k

Programmer
Jun 28, 2001
678
US
I'm struggling with trying to set a filter on a subform based on a combobox value on the parent form. I'm trying to select records from a table
where field = combo15.column(1). The code or queries I use never like the syntax I use for column(1) so I'm trying to load the value into a variable. The table value is long int and the variable is long but I keep getting a type mismatch.

I would really like to get this resolved before the holiday so if someone could help I would really appreciate it.

Thanks..Russ
 
Hi Russ

I've used this without any issues:
Code:
Private Sub cmdFilter_Click()
    If DoCheck Then Me!subfrmComments.Form.RecordSource = getSQL(Me.cboMonth, Me.cboYear)
End Sub

The DoCheck (custom function) is just to insure I'm filtering on correct parameters. If it returns true I have a custom function that returns the SQL. You can write your own. Mine looks like this:
Code:
Private Function getSQL(ByVal sMonth As String, ByVal sYear As String) As String
    Dim pDts As ParamDates
    getParamDates sMonth, sYear, pDts
    getSQL = "SELECT qryIssueRisks.EntryDate, qryIssueRisks.IssuesRisks1, qryIssueRisks.IssuesRisks2, " _
            & "qryIssueRisks.IssuesRisks3, ESComments.Comments " _
            & "FROM ESComments INNER JOIN qryIssueRisks ON ESComments.EntryDate = qryIssueRisks.EntryDate " _
            & "WHERE qryIssueRisks.EntryDate Between #" & CStr(pDts.FirstDate) & "# And #" & CStr(pDts.SecDate) & "# " _
            & "ORDER BY qryIssueRisks.EntryDate DESC;"
End Function
I call some other functions but you get the gist of what's happening. The beauty of this method is that if you are still getting type errors, just include a Debug.Print getSQL(your parameters) and copy and paste in the QBE to find out what the problem is.

Hope this Helps,
Rewdee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top