By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,022 Members | 856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,022 IT Pros & Developers. It's quick & easy.

Recordset Issues

P: 13
Hi there,

does anyone know why when opening a recordset the value is on to EOF ... i want it to stay on the first record ... whenever the recordset is opened.
May 11 '07 #1
Share this Question
Share on Google+
3 Replies


missinglinq
Expert 2.5K+
P: 3,532
If it's going to the End Of File on opening, you've probably unwittingly told it to! How are you determinig that it's going to the End Of File? Do you mean, for instance, that the record showing is the last record, alphabetically, in the record set? Is the form based on a table or a query? If based on a query, is one of the fields sorted Descending instead of Ascending?
May 11 '07 #2

P: 13
hi,

here is the code i'm using.

this code is in another loop (for loop - user defined number of times) and opens works fine the first few times ... then it skips one recordset because the IF statement is true... and then is fine again ... then maybe skips a few more ... that's basically the output ... it's not giving an EOF msg on exactly the same files, ... it just works the way it wants to or something ...

do you think there is something missing?

sometimes it also misses out one or two lines from the search reults.

Expand|Select|Wrap|Line Numbers
  1. txtConnection.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source =" & NetPath & dbfile 
  2. txtRecordset.Open "SELECT " & tab35 & ".prefix, " & tab35 & ".Indexing, " & tab35 & ".extension, " & tab36 & ".Title FROM " & tab35 & " INNER JOIN " & tab36 & " ON " & tab35 & ".Indexing = " & tab36 & ".Indexing", txtConnection, adOpenStatic, adLockOptimistic
  3.  
  4.      If txtRecordset.EOF Then
  5.     'msgbox "No Match in database, please make sure you have selected the right files..."
  6.     document.write("<BR>")
  7.     document.write ("Error Occurred While Processing the file below ... Please Process Again")
  8.     document.write("<BR>")
  9.      Else
  10.     document.write("File Number ") & i+1
  11.     document.write("<BR>")
  12.     document.write("Output Text for file ") & textfilepath 
  13.     document.write("<BR>")
  14.     Set objectwriteFile = objFSO.OpenTextFile(textfilepath, ForAppending, True)
  15.      While Not txtRecordset.EOF
  16.  
  17.     efix = txtRecordset.Fields("prefix")
  18.     xing = txtRecordset.Fields("indexing")
  19.     sion = txtRecordset.Fields("extension")
  20.     itle = txtRecordset.Fields("title")
  21.  
  22.  
  23.     document.write(efix & vbTab)
  24.     document.write(xing & vbTab)
  25.     document.write(sion & vbTab)
  26.     document.write(itle & vbTab)
  27.     document.write("<BR>")
  28.     objectwriteFile.Writeline(efix & vbTab & xing & vbTab & sion & vbTab & itle)
  29.     txtRecordset.MoveNext
  30.      Wend
  31.      End If
  32. objectwriteFile.Close
  33. txtRecordSet.Close    
  34. txtConnection.Close
  35.  
  36.  

If it's going to the End Of File on opening, you've probably unwittingly told it to! How are you determinig that it's going to the End Of File? Do you mean, for instance, that the record showing is the last record, alphabetically, in the record set? Is the form based on a table or a query? If based on a query, is one of the fields sorted Descending instead of Ascending?
May 11 '07 #3

P: 13
Got the answer by trial and error, so just posting for anyone with the same issues in the future.

make sure you have the cursorlocation of the recordset before you open the recordset ... makes the database accessing 100 times faster as well as gives you the right results.

following is the sample code.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Const adUseClient = 3
  3.  
  4. txtRecordset.CursorLocation = adUseClient
  5. txtRecordset.Open
  6.  
  7.  
Hi there,

does anyone know why when opening a recordset the value is on to EOF ... i want it to stay on the first record ... whenever the recordset is opened.
May 15 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.