Data integrity

dott

Registered User.
Local time
Today, 07:19
Joined
Jun 24, 2003
Messages
56
I am trying to create a function that will look through a table, and if it finds a blank entry for a certain field, it will delete it.

I just don't know how to reference the table in order to scan it and modifiy it.
 
Last edited:
Hmm yeah i guess i could. But that seems to prompt the user about deleting data, which i dont want.

Isn't there an easy way to do it through a block of code? Using a for each statement perhaps?

All i want to know is how to reference a table in VB
 
dott,

Code:
Dim dbs As Database
Dim rst As Recordset
Dim sql As String

Set dbs = CurrentDb
sql = "Select * from YourTable"
Set rst = dbs.OpenRecordset(sql)
While Not rst.EOF
   If IsNull(rst!SomeField) Then
      MsgBox("Hey, that field is null")
      ' To change the field
      rst.Edit
      rst!SomeField = "SomeThing"
      rst.Update
   End If
   rst.MoveNext
   Wend

hth,
Wayne
 

Users who are viewing this thread

Back
Top Bottom