Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete data in a field using DAO or whatever in code

Status
Not open for further replies.

jazzz

Technical User
Feb 17, 2000
433
US
How do I move to a field in a table using DAO and delete the data in that field if it don't meet the criteria needed?<br>The table is indexed on itemNumber, field name is payment, table name is tblMasterInfo.&nbsp;&nbsp;Also, the table will be the open table.<br><br>Thanks
 
Myron,<br><br>There are a couple of approaches.&nbsp;&nbsp;You could create an update query on the fly, using your criteria for deletion as a parameter, and update the field to 0 or &quot;&quot; or Null as you wish.<br><br>Or you could create a query that returns the records from which you want to delete data.&nbsp;&nbsp;Create a recordset based on that query and step through the records, setting the field equal to 0 or &quot;&quot; or Null as you wish.<br><br>Kathryn
 
Kathryn,<br>&nbsp;Thank you, want I am attempting to do is use code on a form that if field A is selected and the value of A is B then field C must be Null. If there was a value in C and field A was changed I need to make C Null.&nbsp;&nbsp;So I was attempting to delete any value in C BeforeUpdate using code.
 
Myron,<br><br>I'm glad you gave more detail.&nbsp;&nbsp;If you are using a form, then you shouldn't need to use DAO.<br><br>Do you want to have the change to Field C happen when Field A is selected or changed?&nbsp;&nbsp;Or do you mean that Field A is bound to a list box or combo box from which a value can be selected?<br><br>The code would look, very roughly, like this:<br><br>***Begin Code***<br><br>Sub FieldA_AfterUpdate<br><br>if me!fieldA = &quot;B&quot; then<br>&nbsp;&nbsp;&nbsp;&nbsp;me!fieldC=null<br>end if<br><br>***End Code***<br><br>I'm still not sure that this is what you want.&nbsp;&nbsp;Let me know if I have missed the mark.<br><br>Kathryn
 
Kathryn, both fields are combo boxes. Field A is payment type, Money Order, Credit Card, Check etc.&nbsp;&nbsp;Field B is credit card type Visa, Discover, MasterCard and other.&nbsp;&nbsp;I have Field B.enabled = False unless credit card is selected then Field B.enabled=true.&nbsp;&nbsp;However, if someone selected a credit card type it now shows the card type in field B albeit dimmed I would like to remove the previous selection altogether so it's a blank field again if field A is anything other than a credit card.
 
Kathryn, I must be thinking way to much.&nbsp;&nbsp;I used you code above and the Null worked just fine.&nbsp;&nbsp;So I thank you very much.<br><br>Myron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top