PDA

Click to See Complete Forum and Search --> : New To SQL? Type Mismatch


Bam_BamIR
Aug 17th, 2000, 12:40 PM
getting type mismatch very new to sql any help would be appreciated oh ssql1$,2,sdate$ to and sdatefrom$

sSQL1 = "SELECT * FROM [Service Calls] WHERE [Date] BETWEEN" & "#" & sDateFrom & "#" And "#" & sDateTo & "#" & "ORDER BY Date,ORDER BY Time"
sSQL2 = "SELECT * FROM [Cust Info] WHERE [Cust ID] =" & apptRSResult![Cust ID]

Set apptRSResult = mdiDBMain.objDataBase.OpenRecordset(sSQL1, dbOpenDynaset) 'new rs from sdatefrom to sdateto
Set apptRSPrint = mdiDBMain.objDataBase.OpenRecordset(sSQL2, dbOpenDynaset) 'locate all records with same custid number

JHausmann
Aug 17th, 2000, 12:46 PM
try:

sSQL1 = "SELECT * FROM [Service Calls] WHERE [Date] BETWEEN #" & sDateFrom & "# And #" & sDateTo & "# ORDER BY Date, Time"
sSQL2 = "SELECT * FROM [Cust Info] WHERE [Cust ID] ='" & apptRSResult![Cust ID] & "'"

Bam_BamIR
Aug 17th, 2000, 12:59 PM
the first sql statement worked but i think that the approach on the second was incorrect on my part, what im looking to do is get every record in one table that matches every record in the rs that is created with sSQL1, i was thinking maybe of looping thru the recordset and searching, do you know of another way useing sql?

JHausmann
Aug 17th, 2000, 01:12 PM
No problem. Try:


sSQL2 = "SELECT * FROM [Cust Info] WHERE [Cust ID] in( SELECT [Cust ID] FROM [Service Calls] WHERE [Date] BETWEEN #" & sDateFrom & "# And #" & sDateTo & "# )"

Bam_BamIR
Aug 17th, 2000, 01:33 PM
tnx, do you recommend any specific book for learning sql?