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!

Deleting Query

Status
Not open for further replies.

Jengo

Programmer
Apr 17, 2000
100
US
I have a deleting query that deletes all empty record when you open the form.  But I don't want to it to prompt the user to execute.  I want it to automatically run, how can i do that?
 
Use Code instead.&nbsp;&nbsp;Put this code in your On_Load event of your form.<br>-----------------------------------<br>Private Sub Form_Load()<br>&nbsp;&nbsp;&nbsp;&nbsp;' This routine opens a table and moves to the last record<br>&nbsp;&nbsp;&nbsp;&nbsp;' gets the records count then deletes each record<br>&nbsp;&nbsp;&nbsp;&nbsp;'<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim db As Database, rst As Recordset, x As Integer<br>&nbsp;&nbsp;&nbsp;&nbsp;Set db = CurrentDb<br>&nbsp;&nbsp;&nbsp;&nbsp;Set rst = db.OpenRecordset(&quot;Test&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;rst.MoveLast<br>&nbsp;&nbsp;&nbsp;&nbsp;For x = rst.RecordCount To 1 Step -1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rst.Delete<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rst.MovePrevious<br>&nbsp;&nbsp;&nbsp;&nbsp;Next<br>&nbsp;&nbsp;&nbsp;&nbsp;rst.Close<br>&nbsp;&nbsp;&nbsp;&nbsp;db.Close<br>End Sub<br>---------------------------------<br>OK<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
<br><br>DoCmd.SetWarnings(off)<br>DoCmd.runSQL &quot;DELETE FROM Table1 where field1 is null&quot;<br>DoCmd.SetWarnings(on)<br><br>I use very litle 'DoCmd dot' stuff so check the syntax<br>on 'SetWarnings = Off' / 'SetWarnings(off)'.<br><br><br>..and have fun !<br><br><br> <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top