Help with SQL Select statement

dtaylor89

Registered User.
Local time
Today, 16:05
Joined
Jan 16, 2013
Messages
25
I am trying to write a SELECT statement to count the InitPW from a table where the PWord is null and the textbox on the form "txtNewPass" is = InitPW but some reaseon this isn't working does anyone see something wrong with the below select statement

Dim sqlText As String
sqlText = "SELECT Count(InitPW) as X FROM tblUser WHERE PWord Is Null" & "And " & "InitPW ='" & txtNewPass & "'"

Thanks in advance!
 
"SELECT Count(InitPW) as X FROM tblUser WHERE PWord Is Null And InitPW ='" & txtNewPass & "'"
 
Run-time error 2342

A run SQL action requires an argument consisting of an SQL statement.

This is my error when I run the code
 
Run-time error 2342

A run SQL action requires an argument consisting of an SQL statement.

This is my error when I run the code

How are you trying to use this SQL statement?

You can't use DoCmd.RunSQL because the query is a select statement.
 
The sql statement should be ran after I click a button
 
Could you not use DCount() instead of running SQL?

Something lines of..
Code:
DCount("*", "tblUser", "IsNull(PWord) AND InitPW ='" & txtNewPass & "'")
 

Users who are viewing this thread

Back
Top Bottom