Question : SQL to VBA Syntax

Hello everyone,
I need help for converting SQL to VBA.
Ok first I have this line
Set rstXIRR = dbs.OpenRecordset("select * from indices3 where [Tdate] > #" & Forms!form77!tstart & "#")
I want to add two more criteria . One of them is [Index]= Forms!form77!index1. Other one is [Tdate]< Forms!form77!tend.
Index and Tdate are Field names.
also I need to add these queries inside another line in the code.
I have
nPayments = DCount("Tdate", "Indices3", "[Tdate] > #" & Forms!form77!tstart & "#")
I want to add [Index]= Forms!form77!index1 and  [Tdate]< Forms!form77!tend.
As you can assume that Forms!form77!tstart  and Forms!form77!tend ask the user to enter a start date and an end date. So, I was thinking maybe we can use a between here.
thanks,

Answer : SQL to VBA Syntax

The best way to start on this is to work out the query first on the query builder. Then copy and paste to code and make the minor adjustments. I would think the syntax would be something as follows:

Set rstXIRR = dbs.OpenRecordset("select * from indices3 where [Tdate] > #" & Forms!form77!tstart & "# AND [Index] = " & Forms!form77!index1 & " AND [Tdate] < " & [Tdate]< Forms!form77!tend & ";"  )
Random Solutions  
 
programming4us programming4us