Select Stament

  • Thread starter Thread starter jeanhurtado
  • Start date Start date
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.
 
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;"
 
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.
 
Back
Top