Sql/query Help

ruffroads

New member
Local time
Yesterday, 18:29
Joined
Jun 2, 2004
Messages
1
I'm looking for some help with my SQL string in MS Access 2002. I want to grab all records with a certain "ReportNumber". The report number is set up as a text field but does consist of all numbers. Example : "20039.0001" I know there are records in the table but when I execute the search I get a "No current record error no 3021" error. If I eliminate the WHERE Clause IT works but grabs the entire recordset. This error occurs with the "rs2.MoveFirst" portion of the code.

Thanks in Advance - ruffroads
PS. This happens also when I try to build a simple query around the report number. It will not filter to my search criteria.


See Code below:
--------------------------------------------------------------------------
Dim Db2 As DAO.Database
Dim rs2 As DAO.Recordset
Dim rsA As DAO.Recordset
Dim rptnum2 As String
Dim rptnum3 As String
rptnum2 = Val(Right(Forms!PROJ_MANAGER!projrptsubfrm!ReportNumber, 3))
rptnum3 = Left(Forms!PROJ_MANAGER!projrptsubfrm!ProjectID, 5) & ".0" & CStr(Right(Val((rptnum2 - 1) * 0.001), 3))

Set Db2 = CurrentDb

Set rs2 = Db2.OpenRecordset("SELECT * FROM tbl_PROJATTENDEES WHERE tbl_PROJATTENDEES.ReportNumber =""" & rptnum3 & """;")
Set rsA = Db2.OpenRecordset("SELECT * FROM tbl_PROJATTENDEES WHERE tbl_PROJATTENDEES.ReportNumber =""" & Me!ReportNumber & """;")
If IsNull(rs2) = True Then
MsgBox "No Previous Records!"
Exit Sub
End If
Debug.Print rs2.RecordCount
rs2.MoveFirst
 
Have you tried it with "Real" numbers instead of your variables?
 

Users who are viewing this thread

Back
Top Bottom