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

Delete issue

P: 12
hello all,

Just a quick query

I currently have an hires form where clients place orders,
When an item is selected this would drop the item within a listbox and save within a itemhireline table. If clear is selected half way through an order i want the items within the listbox to be deleted from the tblitemhireline so when the next order is placed the listbox should be empty. It sounds pretty simple but i cannot get it to delete all the items that are linked to this itemhireno.

This is what i have been using - it only deletes one item every time the form is cleared

Set rstclear = database.OpenRecordset("Select * from itemhireline Where itemhirno=" & Forms!frmitemhireform!txtitemhireno)
rstclear.Delete
Feb 27 '08 #1
Share this Question
Share on Google+
2 Replies


Megalog
Expert 100+
P: 378
Set rstclear = database.OpenRecordset("Select * from itemhireline
Where itemhirno=" & Forms!frmitemhireform!txtitemhireno)
rstclear.Delete
Try something like this... There's probably a better way to handle the looping than using a goto.. <shrug> Back up your data first!

Expand|Select|Wrap|Line Numbers
  1. Dim rstclear as DAO.Recordset
  2. Dim itm as Variant
  3.  
  4. Set rstclear = CurrentDb.OpenRecordset("itemhireline", dbOpenDynaset)
  5. Repeat:
  6. rst.FindFirst "itemhirno = " & [Forms]![frmitemhireform].[txtitemhireno]
  7. if rst.nomatch = False Then
  8.      rstclear.Delete
  9.      goto Repeat
  10. end if
  11. Set rstclear = nothing
Feb 27 '08 #2

NeoPa
Expert Mod 15k+
P: 31,769
Expand|Select|Wrap|Line Numbers
  1. Do [criteria]
  2. ...
  3. Loop [criteria]
Expand|Select|Wrap|Line Numbers
  1. While [criteria]
  2. ...
  3. Wend
Expand|Select|Wrap|Line Numbers
  1. For Var = X To Y [Step Z]
  2. ...
  3. Next Var
Feb 28 '08 #3

Post your reply

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