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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting data using update

Status
Not open for further replies.

ade77

Technical User
Jul 17, 2000
4
0
0
GB
Could anyone please help me. I have created a form, which allows users to edit their details in an Access database using update. The problem comes when you try and delete some data, which I was hoping could be achieved by placing a blank space where the original data was. However, this returns an error saying that null values are not allowed. Is there any method which I can achieve this without creating a seperate delete form.
 
You have to set the field to accept zero-length strings in the database.<br><br>Go into Access and open the table in design view. Click on the field name. Now, towards the bottom of the window where it says &quot;Allow Zero Length?&quot;, set the value to &quot;Yes&quot;. That should fix this problem. If not then I'm not sure what the cause is. I haven't found whether there are any performance advantages or disadvantages to having this set one way or the other but I would like to know if anyone has any knowledge of this... <p>--Will Duty<br><a href=mailto:wduty@radicalfringe.com>wduty@radicalfringe.com</a><br><a href= > </a><br>
 
On the processing page, check for the zero length form element and then conditionally create the sql statement based on that.<br><br>pseudocode example:<br><br>'get the info from the post<br>iId = Request.Form(&quot;id&quot;)<br>sName = Request.Form(&quot;name&quot;)<br><br>'if the name is blank<br>If Trim(sName) = &quot;&quot; Then &nbsp;&nbsp;&nbsp;&nbsp;'delete the record<br>&nbsp;&nbsp;&nbsp;&nbsp;sql = &quot;DELETE FROM tbl WHERE dbid = &quot; & iId<br>Else &nbsp;&nbsp;&nbsp;&nbsp;'update the record<br>&nbsp;&nbsp;&nbsp;&nbsp;sql = &quot;UPDATE tbl SET Name = '&quot; & sName & &quot;' WHERE dbid = &quot; & iId<br>End If<br><br>Cn.Execute sql<br><br> <p> Jeff Friestman<br><a href=mailto: > </a><br><a href= View my Brainbench transcript</a><br>Brainbench 'Most Valuable Professional' for ASP<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top