setting date and sub-string in sql command 
Author Message
 setting date and sub-string in sql command

Dear,

    I met one problem. It would be highly appreciated if you can help me.
    First, I want to write sql command in VBA for access 2000 using dao. It
is to set sub-string and date range searching.
I write the following but it display a error.

If IsNull(Me.CONTAIN) Then
     If IsNull(Me.DATETO) And IsNull(Me.datefrom) Then
    Else
    SqlStr = SqlStr & " where (" & Me.filter2 & " between #" & Me.datefrom &
"# and #" & Me.DATETO & "#)"
     End If
Else
    SqlStr = SqlStr & " where " & Me.filter1 & " Like '*" & Me.CONTAIN &
"*'"
End If

Hoping for your help

Faithfully,

Raymond



Fri, 03 Jun 2005 11:32:38 GMT  
 setting date and sub-string in sql command
What error are you getting? That will give a clue as to what is going wrong.

--
Hoping that this is helpful...
       Ken Snell
<MS ACCESS MVP>


Quote:
> Dear,

>     I met one problem. It would be highly appreciated if you can help me.
>     First, I want to write sql command in vba for access 2000 using dao.
It
> is to set sub-string and date range searching.
> I write the following but it display a error.

> If IsNull(Me.CONTAIN) Then
>      If IsNull(Me.DATETO) And IsNull(Me.datefrom) Then
>     Else
>     SqlStr = SqlStr & " where (" & Me.filter2 & " between #" & Me.datefrom
&
> "# and #" & Me.DATETO & "#)"
>      End If
> Else
>     SqlStr = SqlStr & " where " & Me.filter1 & " Like '*" & Me.CONTAIN &
> "*'"
> End If

> Hoping for your help

> Faithfully,

> Raymond



Fri, 03 Jun 2005 12:08:41 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VB6 newbie: date environment sub-command access from forms

2. Passing as string variable from sub to sub

3. eVB Date, Time Setting Command

4. Help with Setting Date from String

5. Passing Date to SQL command Question??

6. SQL string of command object in DataEnvironment

7. SQL string of command object in DataEnvironment

8. Using the IN keyword in a SQL string for a command object

9. Getting date from user to use in a SQL String (Access)

10. Specify date unambiguousely in Sql String

11. Searching for a date in SQL String

12. Dates in SQL strings

 

 
Powered by phpBB® Forum Software