943,580 Members | Top Members by Rank

Ad:
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Aug 19th, 2009
0

Re: Do until loop

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mpande is offline Offline
21 posts
since Jun 2009
Aug 19th, 2009
0

Re: Do until loop

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 & "",
Reputation Points: 31
Solved Threads: 29
Posting Whiz in Training
ProfessorPC is offline Offline
270 posts
since Dec 2007
Aug 24th, 2009
0

Re: Do until loop

Click to Expand / Collapse  Quote originally posted by cguan_77 ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mpande is offline Offline
21 posts
since Jun 2009
Aug 24th, 2009
0

Re: Do until loop

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. "UPDATE product_line set qtydb= qtydb + " & qtydba & " WHERE product_id = " & productid & "",
Reputation Points: 31
Solved Threads: 29
Posting Whiz in Training
ProfessorPC is offline Offline
270 posts
since Dec 2007
Aug 25th, 2009
0

Re: Do until loop

Click to Expand / Collapse  Quote originally posted by cguan_77 ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mpande is offline Offline
21 posts
since Jun 2009
Aug 25th, 2009
0

Re: Do until loop

use Microsoft Calendar Control..go to Project->Components then click Microsoft Calendar Control..
Reputation Points: 19
Solved Threads: 115
Nearly a Posting Virtuoso
cguan_77 is offline Offline
1,317 posts
since Apr 2007
Aug 25th, 2009
0

Re: Do until loop

Click to Expand / Collapse  Quote originally posted by cguan_77 ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mpande is offline Offline
21 posts
since Jun 2009
Aug 25th, 2009
0

Re: Do until loop

you grab its text.
Reputation Points: 31
Solved Threads: 29
Posting Whiz in Training
ProfessorPC is offline Offline
270 posts
since Dec 2007
Aug 25th, 2009
0

Re: Do until loop

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mpande is offline Offline
21 posts
since Jun 2009
Aug 25th, 2009
0

Re: Do until loop

text1.text= calendar1.value
Reputation Points: 19
Solved Threads: 115
Nearly a Posting Virtuoso
cguan_77 is offline Offline
1,317 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Pyramid Issue
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: cells.find in excel





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC