Do until loop

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2009
Posts: 21
Reputation: mpande is an unknown quantity at this point 
Solved Threads: 0
mpande mpande is offline Offline
Newbie Poster

Re: Do until loop

 
0
  #11
Aug 19th, 2009
Originally Posted by ProfessorPC View Post
okay lets see what we can do lol. so you get the data from the product id. you are updating the table with the values in txt boxes? if that is the way your are working it lets try this.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. rs1.Open "UPDATE Stock (qty, stock_date, trans_type, qtydb ) Values (" & qtyfield &", " & stock_datefield &", " & trans_type &", " & qtydbfield &")", updatedb

been a long day hope that works lol
Hi Professor P

Thanks for your help, it's truly appreciated.The update actually works, but then the problem is that it does'nt update the value corresponding with the product_id, instead it updates all the all the values here is the code I'm using:
db.Open "DSN=eco;Password=andile;User ID=eco;Data Source=waterdb"
Set rs = New ADODB.Recordset

rs.Open "select product_id,qty,qtydb from product_line where product_id=" & Me.productid.Text & " ", db
Do While Not rs.EOF
If productid = rs!product_id Then
Set updatedb = New ADODB.Connection
updatedb.Open "DSN=eco;Password=andile;User ID=eco;Data Source=waterdb"

Set rs1 = New ADODB.Recordset

qtydba = qtydba + qty

updatedb.Execute "UPDATE product_line set qtydb=" & qtydba & "", updatedb

Else: MsgBox ("invalid product_id")
rs.Close
End If
Loop
db.Close

Could you please help.
Thanks.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 252
Reputation: ProfessorPC is an unknown quantity at this point 
Solved Threads: 27
ProfessorPC ProfessorPC is offline Offline
Posting Whiz in Training

Re: Do until loop

 
0
  #12
Aug 19th, 2009
ok we need to set it where the productid = the productid
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. "UPDATE product_line set qtydb=" & qtydba & " WHERE product_id = " & productid & "",
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 21
Reputation: mpande is an unknown quantity at this point 
Solved Threads: 0
mpande mpande is offline Offline
Newbie Poster

Re: Do until loop

 
0
  #13
Aug 24th, 2009
Originally Posted by cguan_77 View Post
hi, this might give you an idea:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. num = 1 ' initialize counter
  2. 'rs is the reference to your recordset change if needed
  3. Do While Not rs.EOF
  4. ' See if the data has been found
  5. If product_id = rs!product_id Then
  6. 'do something here
  7. End If
  8.  
  9. ' If not found move to the next record.
  10. num = num + 1
  11. rs.MoveNext
  12. Loop

and just curious why you need me on this code;
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. dim productid as integer
  2. productid=me.productid.text
why not do like this:
productid=productid.text

i hope it helps..
Hi Proffessor P

I guess now I know why they call you proffessor P, thanks for you help, it works now.
The other problem was that I want to increment the qtydb value, but it wont increment, this is what I'm using qtydb=qtydb+qty, it does the calculation, it's just that, it doubles the qty value, instead of giving me the qtydb value in the database and then adding it with the qty value.
Please Help.
Thanks.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 252
Reputation: ProfessorPC is an unknown quantity at this point 
Solved Threads: 27
ProfessorPC ProfessorPC is offline Offline
Posting Whiz in Training

Re: Do until loop

 
0
  #14
Aug 24th, 2009
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. "UPDATE product_line set qtydb= qtydb + " & qtydba & " WHERE product_id = " & productid & "",
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 21
Reputation: mpande is an unknown quantity at this point 
Solved Threads: 0
mpande mpande is offline Offline
Newbie Poster

Re: Do until loop

 
0
  #15
Aug 25th, 2009
Originally Posted by cguan_77 View Post
hi, this might give you an idea:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. num = 1 ' initialize counter
  2. 'rs is the reference to your recordset change if needed
  3. Do While Not rs.EOF
  4. ' See if the data has been found
  5. If product_id = rs!product_id Then
  6. 'do something here
  7. End If
  8.  
  9. ' If not found move to the next record.
  10. num = num + 1
  11. rs.MoveNext
  12. Loop

and just curious why you need me on this code;
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. dim productid as integer
  2. productid=me.productid.text
why not do like this:
productid=productid.text

i hope it helps..
Hi Proffessor P
Thanks for the help, it works.
Another thing is that, how can you attach a calender, on the date textbox, so that instead of the user entering the date, they simply choose the date from the calendar.
Thanks.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1,122
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 93
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

Re: Do until loop

 
0
  #16
Aug 25th, 2009
use Microsoft Calendar Control..go to Project->Components then click Microsoft Calendar Control..
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 21
Reputation: mpande is an unknown quantity at this point 
Solved Threads: 0
mpande mpande is offline Offline
Newbie Poster

Re: Do until loop

 
0
  #17
Aug 25th, 2009
Originally Posted by cguan_77 View Post
use Microsoft Calendar Control..go to Project->Components then click Microsoft Calendar Control..
Hi cguan_77
It's been long, thanks, I'v found the control, but now how(code) do you enter the date into the database with the control.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 252
Reputation: ProfessorPC is an unknown quantity at this point 
Solved Threads: 27
ProfessorPC ProfessorPC is offline Offline
Posting Whiz in Training

Re: Do until loop

 
0
  #18
Aug 25th, 2009
you grab its text.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 21
Reputation: mpande is an unknown quantity at this point 
Solved Threads: 0
mpande mpande is offline Offline
Newbie Poster

Re: Do until loop

 
0
  #19
Aug 25th, 2009
Originally Posted by ProfessorPC View Post
you grab its text.
ok, what do you call the control, you know with a textbox, it is .text, I'm trying to use the normal way, dim date as string, date=calendar1._____, is what I don't know, have tried most of them, but they give me an error(type mismatch) at runtime.
Thanks
Cheers.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1,122
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 93
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

Re: Do until loop

 
0
  #20
Aug 25th, 2009
text1.text= calendar1.value
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 1750 | Replies: 27
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC