D
Deleted member 8621
Guest
I have the following code:
Dim rs As DAO.Recordset
Dim vrmo As Integer
Dim mdl As String
Dim snum As String
Dim strSQL As String
mdl = Forms!frmAdminEntry!Text45
snum = Forms!frmAdminEntry!Text47
vrmo = Forms!frmAdminEntry!Text26
strSQL = "SELECT TOP " & vrmo & " Model, SN, Date, [1stMeter], [1stMtrRollover], "
strSQL = strSQL & "[2ndMeter], [2ndMtrRollover] "
strSQL = strSQL & "FROM tblMeterData "
strSQL = strSQL & "WHERE (((Model)='" & mdl & "') AND ((SN)= '" & snum & "')) "
strSQL = strSQL & "ORDER BY Date DESC;"
Set rs = CurrentDb.OpenRecordset(strSQL)
DoCmd.OpenForm "frmViewMeterData", , strSQL
Do Until rs.EOF
Debug.Print rs!SN
rs.MoveNext
Loop
My Debug.Print rs!SN shows the correct # of records in the imediate window.
Problem
My DoCmd.OpenForm returns all the records the WHERE clause refers to without paying any attention to the TOP clause.
Where and how do I need to open the form. It doesn't seem to be here???
thanks
matthew (the posting king
Dim rs As DAO.Recordset
Dim vrmo As Integer
Dim mdl As String
Dim snum As String
Dim strSQL As String
mdl = Forms!frmAdminEntry!Text45
snum = Forms!frmAdminEntry!Text47
vrmo = Forms!frmAdminEntry!Text26
strSQL = "SELECT TOP " & vrmo & " Model, SN, Date, [1stMeter], [1stMtrRollover], "
strSQL = strSQL & "[2ndMeter], [2ndMtrRollover] "
strSQL = strSQL & "FROM tblMeterData "
strSQL = strSQL & "WHERE (((Model)='" & mdl & "') AND ((SN)= '" & snum & "')) "
strSQL = strSQL & "ORDER BY Date DESC;"
Set rs = CurrentDb.OpenRecordset(strSQL)
DoCmd.OpenForm "frmViewMeterData", , strSQL
Do Until rs.EOF
Debug.Print rs!SN
rs.MoveNext
Loop
My Debug.Print rs!SN shows the correct # of records in the imediate window.
Problem
My DoCmd.OpenForm returns all the records the WHERE clause refers to without paying any attention to the TOP clause.
Where and how do I need to open the form. It doesn't seem to be here???
thanks
matthew (the posting king
