|
-
Sep 1st, 2000, 05:36 AM
#1
Thread Starter
Evil Genius
HELP PLEASE!
Code:
Do While Not Rs.EOF
Rs.Delete
Rs.MoveNext
Loop
I am calling the above from Excel, rs is my imaginatively named variable for a recordset.
All I would like to do is delete everything from a recordset when Excel closes (keeping column headers etc, would prefer not to create table each time Excel page starts). Can anyone point me in the right direction here please?
Thank you! this is GREATLY appriciated as this is just starting to get to me...
Alex read
-
Sep 1st, 2000, 05:41 AM
#2
Lively Member
Is your starting point the beginning of the recordset?
Do you need rs.movefirst before your loop?
-
Sep 1st, 2000, 05:55 AM
#3
Thread Starter
Evil Genius
But ...
Thank you for responding Michael, unfortunatley I tried this one & it hasn't worked, I have also been trying:
Code:
for i = 1 to rs.recordcount
Do While Not Rs.EOF
rs.movefirst
Rs.Delete
Rs.MoveNext
Loop
next i
incase that helped, but nothing yet, is there anything else wrong with the above ?
Thank you,
Alex Read
-
Sep 1st, 2000, 06:27 AM
#4
Lively Member
I would stick with your original code - with rs.movefirst before the loop (outside it).
Your latest code should work but the extra lines serve no useful purpose and only help to confuse the issue.
It's not a read-only recordset is it?
-
Sep 1st, 2000, 06:31 AM
#5
Thread Starter
Evil Genius
how stupid am I ...
Thank you once again Michael, god I love this forum!
You were right, I had placed the rs.movenext in the wrong place!
Thank you,
Alex
-
Sep 1st, 2000, 07:00 AM
#6
Lively Member
You're welcome.
I would say something like "what a silly-billy" if I hadn't done any stupid things myself!!! But I won't!!!
-
Sep 1st, 2000, 08:39 AM
#7
Fanatic Member
"select * from cars where prodnum < 183"
rs.movefirst
do until rs.eof
rs.delete
rs.movenext
loop
-------------------------------
or with SQL
"delete * from cars where prodnum < 183"
--------------------------------
same result
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Sep 1st, 2000, 09:14 AM
#8
Fanatic Member
Syntax error (Sorry to sound like a *****)
"delete * from cars where prodnum < 183"
should be
"delete from cars where prodnum < 183"
Without the Star! I often mistype that myself so all is forgiven
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
Sep 1st, 2000, 09:40 AM
#9
Fanatic Member
sorry, wrote it quick
its the concept that counts!
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Sep 3rd, 2000, 06:12 AM
#10
Lively Member
Paul is right - SQL is far superior.
However, I also know how annoying it is when you can't get what should be a simple piece of code to work. Been there - Done that - Got the T-shirt!!!
-
Sep 4th, 2000, 02:16 AM
#11
Thread Starter
Evil Genius
I'd definitley agree with that one Michael, I too have been there, didn't get the t-shirt mind...
-
Sep 4th, 2000, 06:01 AM
#12
Conquistador
i hate databases, they are a pain!!!!
-
Sep 4th, 2000, 06:03 AM
#13
Thread Starter
Evil Genius
da_silvy,
Can you think of a VB app without a database? 15,000 registry entries to access or putting all the info in a text file? AAARRRGGGHHHH!
I guess they do serve a useful purpose, but coding with them can be ridiculous sometimes (my one I should have spotted here but...)
-
Sep 4th, 2000, 06:11 AM
#14
Fanatic Member
I think they only get annoying when everything has to be split into half a million text boxes for a user...
As far as data retrieval and manipulation goes I think they're great. I usually chuck the relevant data to an array or UDT right at the start and work from there. Although just connecting a front end can be pretty tedious.
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
Sep 4th, 2000, 06:28 AM
#15
Thread Starter
Evil Genius
Paul, think of a vb learning edition, then think of NO visdata (whatever it's called), then think of NO tools to help databases communicate with VB forms, but rather everything drawn & connected manually (the data control works for very simple parts).
Ok, now think of computer out the window, then of men in white coats....
From your signature I take it you don't have the learning ed,
I feel musically inspired here:
"wouldn't it be good to be in your shoes" !
-
Sep 4th, 2000, 07:48 AM
#16
Fanatic Member
Close, but no cigar!
I learned DB from ASP connecting to SQL server with ADO(and SQL server admin)
Then found in VB that if you reference the ADO (forget the activeX controls) it's all the same code but with real data types. Use SQL syntax strings to do the work rather than screwing around with the finer points of the RS.
I bought the "DB Programming with VB 6" book which is great but I haven't read as much of if as I would like, I like just staying with the SQL.
No tool, not data aware controls, just a home made text editor for ASP (which I left at my last company and lost the source )
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
Sep 4th, 2000, 07:55 AM
#17
Thread Starter
Evil Genius
-
Sep 5th, 2000, 02:46 AM
#18
Conquistador
they may be useful, but i still don't like coding them!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|