| | |
Do until loop
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2009
Posts: 21
Reputation:
Solved Threads: 0
•
•
•
•
okay lets see what we can dolol. 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)
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
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.
•
•
Join Date: Dec 2007
Posts: 252
Reputation:
Solved Threads: 27
ok we need to set it where the productid = the productid
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
"UPDATE product_line set qtydb=" & qtydba & " WHERE product_id = " & productid & "",
•
•
Join Date: Jun 2009
Posts: 21
Reputation:
Solved Threads: 0
•
•
•
•
hi, this might give you an idea:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
num = 1 ' initialize counter 'rs is the reference to your recordset change if needed Do While Not rs.EOF ' See if the data has been found If product_id = rs!product_id Then 'do something here End If ' If not found move to the next record. num = num + 1 rs.MoveNext Loop
and just curious why you need me on this code;
why not do like this:Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
dim productid as integer productid=me.productid.text
productid=productid.text
i hope it helps..
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.
•
•
Join Date: Dec 2007
Posts: 252
Reputation:
Solved Threads: 27
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
"UPDATE product_line set qtydb= qtydb + " & qtydba & " WHERE product_id = " & productid & "",
•
•
Join Date: Jun 2009
Posts: 21
Reputation:
Solved Threads: 0
•
•
•
•
hi, this might give you an idea:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
num = 1 ' initialize counter 'rs is the reference to your recordset change if needed Do While Not rs.EOF ' See if the data has been found If product_id = rs!product_id Then 'do something here End If ' If not found move to the next record. num = num + 1 rs.MoveNext Loop
and just curious why you need me on this code;
why not do like this:Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
dim productid as integer productid=me.productid.text
productid=productid.text
i hope it helps..
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.
•
•
Join Date: Jun 2009
Posts: 21
Reputation:
Solved Threads: 0
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.
Thanks
Cheers.
![]() |
Similar Threads
- Help with gui loop. (C)
- Loop...without the loop (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Pyramid Issue
- Next Thread: cells.find in excel
Views: 1769 | Replies: 27
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows




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.


