If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Help with update

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-10-04, 07:26
nimrodswork124 nimrodswork124 is offline
Registered User
 
Join Date: Mar 2004
Location: Groningen, Netherlands
Posts: 1
Red face Help with update

I'm trying to update a stored value in a table using the following code. It gets the criteria from a subform. It works well when ther is only one field in the subform but only updates the first record when there are multiple rows in the subform. Can anyone take a look at the code and tell me what I'm doing wrong?

Private Sub cmdAddRec_Click()

Dim frm As Form

Set frm = [Forms]![2,3,1 Binnengekomen Bestellingen]

Dim db As Database
Dim rs As DAO.Recordset
Dim strSQL As String

Set db = CurrentDb
strSQL = "SELECT * FROM Artikelen WHERE Artikelnr = &_
""& frm![te verwachten bestelling subform]!Artikelnr & " ;"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)

rs.MoveFirst
Do While Not rs.EOF
rs.Edit
rs.Fields("Voorraad").Value = frm![te verwachten bestelling subform]!Aantal + frm![te verwachten bestelling subform]!Voorraad
rs.Update
rs.MoveNext
Loop

rs.Close
Set rs = Nothing
Set db = Nothing

End Sub
Reply With Quote
  #2 (permalink)  
Old 03-10-04, 09:04
Kakha Kakha is offline
Registered User
 
Join Date: Feb 2004
Posts: 199
you should have posted this in MS Access thread

is this correct
strSQL = "SELECT * FROM Artikelen WHERE Artikelnr = &_
""& frm![te verwachten bestelling subform]!Artikelnr & " ;"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)

do you filter a Table "Artikelen" by field "Artikelnr", in this case you will get a recordset with same "Artikelnr" field, and I'm not shure about
frm![te verwachten bestelling subform]!Artikelnr , you get a criterya from the subform, I suppose that you should take criteria from parent form's controll, describe your task more carefully.
__________________
MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On