views:

1915

answers:

1

Can someone tell what is wrong with this query?

sqltext = "SELECT utyp, count(*) AS anzahl
           INTO UTYP_Anzahl FROM 01_umwelt 
           WHERE [01_umwelt].status = Me.Controls(""STATUS"").Value 
           GROUP BY utyp;"

I am getting run time error 3075.

+2  A: 

The SQL you are using is not valid. You must escape the query string when adding a reference to a control. Also, you can get the control directly by it's name. Try the following:

sqltext = "SELECT utyp, count(*) AS anzahl INTO UTYP_Anzahl " _
        & "FROM 01_umwelt WHERE [01_umwelt].status = " _
        & STATUS.Value _
        & " GROUP BY utyp;"
birger
In Access, the default property of a control is .VALUE, so it's entirely unnecessary to use it.
David-W-Fenton