By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,379 Members | 3,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,379 IT Pros & Developers. It's quick & easy.

Delete

P: 49
Hello All,

Currently i have a transaction list form which displays all the transactions which have been saved.
If the client no longer requires the order, there is a remove button which would delete this: see code below
This works fine,it deletes all the items within the listbox and client details but i want it to update the stock levels for all the items within the listbox when remiove is prssed.

Would anyone know how this can be achieved?
[code]

database.Execute ("Delete * from tbltransaction Where Hireno = " & Chr(34) & Forms!frmtransactionlist!txthireno) & Chr(34)

dbase.Execute ("Delete * from tbltransactionline Where hireno =" & Forms!frmtransactionlist!txthireno)

[code]

I think the best way to do this for me is via a loop method, but im not too sure how to achieve this

Any help would be appreciated
Mar 19 '08 #1
Share this Question
Share on Google+
2 Replies


ADezii
Expert 5K+
P: 8,638
Hello All,

Currently i have a transaction list form which displays all the transactions which have been saved.
If the client no longer requires the order, there is a remove button which would delete this: see code below
This works fine,it deletes all the items within the listbox and client details but i want it to update the stock levels for all the items within the listbox when remiove is prssed.

Would anyone know how this can be achieved?
[code]

database.Execute ("Delete * from tbltransaction Where Hireno = " & Chr(34) & Forms!frmtransactionlist!txthireno) & Chr(34)

dbase.Execute ("Delete * from tbltransactionline Where hireno =" & Forms!frmtransactionlist!txthireno)

[code]

I think the best way to do this for me is via a loop method, but im not too sure how to achieve this

Any help would be appreciated
You will have to provide much more detailed information than this, such as:
  1. Table names.
  2. Fields contained within these Tables & their Data Types.
  3. Primary Key Fields in Tables and their Data Types.
  4. Relationships between Tables, and the Parent and Child Field names.
  5. Row Source for the List Box.
  6. Bound Column for the List Box.
  7. Table & Field where the Stock levels are stored.
  8. etc.
Mar 19 '08 #2

P: 19
You would need to setup some variables to hold the values before you deleted them. You would pull these items using a select statement, then set the values. For example:
Dim strSql as string
Dim rs as recordset
Dim iItem as integer
dim sItemDef as string
dim strsql2 as string


strSql-"Select * from mytable where fldItemID = " & YourItemID & "
set rs=currentdb.openrecordset(strsql)

if rs.eof then
exit sub
else
'keep going
end if

do until rs.eof

iItem=rs.fields("fldItemid").value
sItemdef=rs.fields("fldItemDef").value 'Where the quoted names represent your field names

strsql2="insert into myinventorytable (flditemid,flditemdef) VALUES (" & item & ", " & sItemdef & ")"

docmd.runsql(strsql)

rs.movenext
loop
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''

You could run your delete query after you were done with everything, or include it in the loop to do it on an item by item basis
hope this helps
Mar 19 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.