UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> how to use a button to delete value from field in table    
 
   
cfcobalt
post Nov 29 2007, 12:40 PM
Post #1

New Member
Posts: 4



I am trying to have a button created that when it is cllicked on the form, three fields associated within the record source for that form are emptied or created as null, basically to override a previous value so that those fields in the form are empty.

How can I use a button to make three fields that are attached to a table through the form, empty? Can someone help pls.
Go to the top of the page
 
+
Sligo
post Nov 29 2007, 01:09 PM
Post #2

UtterAccess VIP
Posts: 972
From: Indianapolis, IN (between Terre Haute & Muncie)



Welcome to UtterAccess!!!!!


If your table is bound to the form, and you are looking at the current record, what you need is pretty simple:

CODE
private sub cmdDelete_Click()

me.field1=null
me.field2=null
me.field3=null

end sub


This would have the same effect if the user entered the field and deleted the data.

There are a zillion variations to this that can be applied or considered. Here are a few:
1. Do you want to stop and ask the user "Are you sure?"
2. Is the data we're deleting NOT bound in our current form?
3. Are the target fields set to not allow nulls?

I hope this helps.

- Sligo
Go to the top of the page
 
+
cfcobalt
post Nov 29 2007, 01:22 PM
Post #3

New Member
Posts: 4



thx. This will only delete the value in that record only for those fields and not all records for those fields in the table?
Go to the top of the page
 
+
cfcobalt
post Nov 29 2007, 01:30 PM
Post #4

New Member
Posts: 4



when I did this, it said the following

'You Can't Assign a Value to this object'

this is what I put in the code of the button on the form

Private Sub cmdOverride_Click()

Dim stDocName As String

Me.strSig = Null
Me.strStmt = Null
Me.blnDone = False

stDocName = "frmStart"
DoCmd.Close
DoCmd.OpenForm stDocName

End Sub
Go to the top of the page
 
+
cfcobalt
post Nov 29 2007, 02:04 PM
Post #5

New Member
Posts: 4



nevermind. I think I got it. thx again!
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 25th May 2013 - 08:30 AM