Question : loop through tables using existing table to find NULL values

Hi Experts,

I Have a table called table1:
field1:(Autonumber),
field2:TableName,
field3:FieldName

e.g first record of Table1 is:

1,BeerDelivery, DeliveryDate

which corresponds to a Table called BeerDelivery which has a field called DeliveryDate.

I want to use this Table1 to loop through all tables in an Access Database where the table1.fieldname3 IS NULL.So where the DeliveryDate field is NULL (for each record) and then display the results INTO another table, showing:

TableName, FieldName + "IS NULL"

e.g.  
BeerDelivery,DeliveryDate IS NULL  
BeerDelivery,DeliveryDate IS NULL

Unfortunately I do not know what each tables PK will be and not even the data type but if I can bring through all the fields for each record in each table and display this:

e.g:

BeerDelivery,DeliveryDate IS NULL, REST OF FIELDS,...  
BeerDelivery,DeliveryDate IS NULL, REST OF FIELDS,...  
FruitDelivery,DeliveryDate IS NULL, REST OF FIELDS,...  

If there is an easier way of doing this - great!

Answer : loop through tables using existing table to find NULL values

maybe i'm missing something, but can't you use something like this?

i also added some code by which you can find the fields type. see http://msdn.microsoft.com/en-us/library/bb208695.aspx for possible results.

PS: i think string fields are never NULL, but they are "" (empty string), so if you don't know what type the FieldName field is you might need some more code to correct for this.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
'code to loop though all field in table one'
Dim db As DAO.Database
Set db = CurrentDb
Dim rs As Recordset
Set rs = db.OpenRecordset("table1")
While Not rs.EOF
    'if there is no record where the fieldname not is null then insert data to another table (replace text between < > by what you need'
    If IsNull(DLookup(rs("FieldName"), rs("TableName"), "NOT " & rs("FieldName") & " IS NULL")) Then
        DoCmd.RunSQL ("INSERT INTO (TableName, ) VALUES('" & rs("TableName") & "', '" & rs("FieldName") & " IS NULL')")
    End If
    rs.MoveNext
Loop


'code to het the field type
Dim db As DAO.Database
Set db = CurrentDb
Dim tdf As DAO.TableDef
Set tdf = db.TableDefs()
Dim fld As field
Set fld = tdf()
fld.Yype
Random Solutions  
 
programming4us programming4us