|
-
Mar 16th, 2000, 10:32 PM
#1
Thread Starter
Addicted Member
Would anyone know the code ( i am using access 97) to check the database for an empty record when the program loads and delte any empty records in the database.
for example in my program if someones computer happens to freeze in the midst of doing an add new a blank record would be added to the database so i was thinking that if this happens i could resolve it by having the program look through the database and delete any empty records.
any ideas on this?
-
Mar 17th, 2000, 04:46 AM
#2
The best way is to restrict the user of adding an empty record.
But if you still want to delete an empty record, then you can do something like this. Add a reference to Microsoft ActiveX library 2.1 (or select the highest version you have installed), then use the code like this:
Code:
Dim cn As New ADODB.Connection
cn.Provider = "Microsoft.Jet.OLEDB.3.51"
cn.Open "C:\MyDB.mdb", "admin", ""
cn.Execute "Delete MyTable Where (Field1 Is Null And Field2 Is Null) Or (Field1 = "" And Field2 = "")
Assuming that:
C:\MyDB.mdb is my database.
MyTable is a table in the database
Field1 and Field2 are two fields in the MyTable
-
Mar 21st, 2000, 03:47 AM
#3
New Member
It would be better to build your form with unbound controls and then only post them when each control has the data required.
Or run a delete query each time the form is loaded and remove those records that incomplete.
Hope this helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|