Select Stament

J

jeanhurtado

Hi, I have a problem with the select statement. The code is the
following:

************************************************************************************************************

Private Sub cmdOk_Click()
Dim rstTickets As ADODB.Recordset
Dim strSQL As String
Dim nTickets As Integer

nTickets = Val(txtticketqty.Value)

Set conDatabase = CurrentProject.Connection
strSQL = "SELECT * FROM CycleCount WHERE TICKETDATE = " & Null

Set rstTickets = New Recordset
rstTickets.Open strSQL, conDatabase, adOpenDynamic,
adLockOptimistic

With rstTickets
For x = 1 To nTickets
!ticketdate = txtTicketDate
.Update
.MoveNext
Next
End With

rstTickets.Close
conDatabase.Close
Set rstTickets = Nothing
Set conDatabase = Nothing

DoCmd.Close acForm, "CYCLE COUNT TICKETS", acSaveYes


End Sub
**********************************************************************************************************************

The meaning of this code is to insert the date that are contain in a
textbox into the ticketdate null fields in a table(Cycle Count) but
when I run the code it tell me the following error:

Run-Time error '-2147217900 (80040e14)':

Syntax error (missing operator) in query expression 'TICKETDATE='.

I have review the error but all is good I also have examples that
shows me that in the select statement when can use the = operator and
then use " then & and value. Can you help me Thnaks so much for your
anticipated help.
 
A

Allen Browne

You cannot compare something to null, and concatenating a Null onto the end
of a string does nothing useful.

I think you are trying to get this result:
strSQL = "SELECT * FROM CycleCount WHERE TICKETDATE Is Null;"
 
J

jeanhurtado

Mr. Allen Browne

That's what I want . Thanks you sir for helping, now is
working. Thanks for explain me in detail. I'm currently looking for
books and tips to lear Access also VBA. Your site is extremely useful
to me. Thanks for all. God Bless you.
 

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

Invalid use of New Keyword 1
Syntax error? 2
VBA HELP 1
Problem with some replace code 2
update table records from form 6
error with my ADO code! 2
VB INSERT INTO 8
result from sql query in recordset 3

Top