Delete

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • goldstar
    New Member
    • Jan 2008
    • 49

    Delete

    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.Execut e ("Delete * from tbltransaction Where Hireno = " & Chr(34) & Forms!frmtransa ctionlist!txthi reno) & Chr(34)

    dbase.Execute ("Delete * from tbltransactionl ine Where hireno =" & Forms!frmtransa ctionlist!txthi reno)

    [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
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by goldstar
    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.Execut e ("Delete * from tbltransaction Where Hireno = " & Chr(34) & Forms!frmtransa ctionlist!txthi reno) & Chr(34)

    dbase.Execute ("Delete * from tbltransactionl ine Where hireno =" & Forms!frmtransa ctionlist!txthi reno)

    [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.

    Comment

    • Fiddler2
      New Member
      • Mar 2008
      • 19

      #3
      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.op enrecordset(str sql)

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

      do until rs.eof

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

      strsql2="insert into myinventorytabl e (flditemid,fldi temdef) VALUES (" & item & ", " & sItemdef & ")"

      docmd.runsql(st rsql)

      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

      Comment

      Working...