English 中文(简体)
使用 form子箱将过滤器应用到电线上。
原标题:Using form combo boxes apply a filter to a query

我认为我很接近这一点,但可以排除过滤过程。

tblIndex(PrimaryCat,SubCat,UserID,Year)
tblResults(SubCat,UserID)

我的表格有两只 com子和一个 but子。 ComboBox1有 t。 小学价值和ComboBox2的年价值。

我想的是,当突击式指挥塔顿时,当 com波箱的数值被作为拖网顶的过滤器使用时,就会打开显示SubCat和用户ID值清单的灯塔。

这是否有意义?

我拥有为模仿Results而确定的形式的记录。 采用这一方法,在过滤某些知识方面,仅需要增加:

私人分立方厘米

Dim strSQL As String

strSQL = "SELECT SubCat, UserID " & _
         "FROM tblIndex " & _
         "WHERE PrimaryCat = [strCat] AND Year = [strYear] " & _
         "GROUP BY SubCat, UserID"

DoCmd.OpenQuery "strSQL"

结尾处

EDIT:

我不敢肯定,如果允许我回答我自己的问题,但我拟定解决办法。 I > used INTO to put the results into a temp table I can further editede using:

私人分立方厘米

Dim strSQL As String

strSQL = "SELECT SubCat, UserID INTO tblTemp " & _ "FROM tblIndex " & _ "WHERE PrimaryCat = " & cboPrimaryCat.Value & " AND Year = " & >cboYear.Value & _ " GROUP BY SubCat, UserID"

DoCmd.RunSQL strSQL

结尾处

问题回答

完成这项工作。 Can t 不能先存放在一间电梯。 解决办法是:

Private Sub cmdGo_Click()
    Dim qdfCurr As DAO.QueryDef
    Dim strSQL As String

    strSQL = "SELECT SubCat, UserID " & _
             "FROM tblIndex " & _
             "WHERE PrimaryCat  =  " & strCat.Value & "  AND Year =  " & strYear.Value & _
             "  GROUP BY SubCat, UserID"

    On Error Resume Next
    Set qdfCurr = CurrentDb.QueryDefs("TempQuery")
    If Err.Number = 3265 Then
        Set qdfCurr = CurrentDb.CreateQueryDef("TempQuery")
    End If

    qdfCurr.SQL = strSQL
    DoCmd.OpenQuery "TempQuery"
End Sub

我认为,这项工作将继续下去。 与温室表合作更为复杂。 想象你们有50个问问问问问问,有相应的问答!

Private Sub cmdGo_Click()

Dim strSQL As String

strSQL = "SELECT SubCat, UserID " & _
         "FROM tblIndex " & _
         "WHERE PrimaryCat = " & Forms!FormName![strCat] & " AND Year = " & Forms!FormName![strYear] " " & _
         "GROUP BY SubCat, UserID"

DoCmd.OpenQuery strSQL

End Sub




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签