Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with rs.EOF code for Select statement

Status
Not open for further replies.

vamoose

Programmer
Oct 16, 2005
320
MX
I am using Access 2000 and the following code:

Dim rs As Object
Dim SQLa As String
SQLa = "Select M83 from Machines M83 = " & Auto
Set rs = CurrentDb().OpenRecordset(SQLa)
***If EOF code needed here ****
rs.Close
Set rs = Nothing

I have been trying to use this code:

If rs.EOF = True Then......

But this does not seem to work, it never becomes True Or False.

Thank you for the assistance.
 
Perhaps this ?
SQLa = "Select M83 from Machines [!]WHERE[/!] M83 = " & Auto

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry, I should have proof read my post better. The where clause is present. Am I missing something, I thought that:

If rs.EOF = True would work. I have used this before and it works fine with an ADODB recordset and connention.

Any ideas are appreciated. Thank you
 
Try this:
If rs.EOF Or rs.BOF Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya vamoose . . .

Try this (full DAO). Note: The code requires [purple]Microsoft DAO 3.6 Object Library[/purple] to run. To [blue]check/install[/blue] the library, in any code window click [blue]Tools[/blue] - [blue]References...[/blue] In the listing find the library and [blue]make sure its checked.[/blue] Then using the up arrow, [purple]push it up as high in priority as it will go[/purple]. Click OK.
Code:
[blue]   Dim db As DAO.Database, rst As DAO.Recordset, SQL As String
   
   Set db = CurrentDb
   Set SQL = "SELECT M83 " & _
             "FROM Machines " & _
             "WHERE (M83 = " & Auto & ");"
   If rst.EOF Then
      MsgBox "No Records Returned!"
   Else
      [green]'Your code if records exist[/green]
   End If

   Set rst = Nothing
   Set db = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Is M83 a numeric field? (I notice there are no apostrophe-delimiters for a character field.)

The best way I've found to debug a recalcitrant SQL statement is to copy/paste it into an Access query and try to run it. If there's a syntax problem, you'll learn pretty quickly; if the query returns data, you've got a program problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top