S
SEAN DI''''ANNO
Vincent Johns gave me some invaluable advice in the code for loop within a
loop. It also introduced me to a union query which I did not know existed
but is obviously very useful for the purpose I need. He also kindly gave me
some sample code for looking at fields and deciding a data score. This code
has set of a brain wave for me..(highly unusal) and I would like to know if
my thoughts are realistic.
The current code relies on the validation rules being very much down to me
to keep updated. I.e. Now some keeps entering "Not important" for address_1.
From the code I could just add it under case_1 but it would ne nice if the
validation checks were in some way maintanable by the users who will
eventually use the database.
Therefore, I have a database which uses a switchboard method of menues..i.e.
switchboard items. Could I use this method within my database; So instead
of switchboard items, I would have fault items and the case values would be
looking for an item?
Public Function DataScore( _
ByVal RecordID As Long) _
As Integer
'ByVal RecordID As Long 'Primary key of record
Dim CurrentRecord As Recordset 'Record identified _
by RecordID key value
Dim fldField As Field 'One of the data fields
'Grab the selected record
Set CurrentRecord = CurrentDb.OpenRecordset _
("SELECT * FROM [ContactList] " _
& "WHERE [ContactList_ID] = " _
& RecordID & ";", _
dbOpenSnapshot)
'Start by assuming all fields to be valid
DataScore = CurrentRecord.Fields.Count
For Each fldField In CurrentRecord.Fields
'Look for whatever might be wrong in the field
Select Case fldField.Name
Case "Contact Name"
If Right$(fldField.Value, 5) = "troyd" _
Then DataScore = DataScore - 1
If UCase$(Left$(fldField.Value, 1)) = "X" _
Then DataScore = DataScore - 1
Case "Address 1"
If InStr(fldField.Value, "Baker") > 0 _
Then DataScore = DataScore - 1
Case "Post Code"
If Left$(fldField.Value, 3) = "2V5" _
Then DataScore = DataScore - 1
End Select 'Case fldField.Name
Next fldField
End Function 'DataScore()
loop. It also introduced me to a union query which I did not know existed
but is obviously very useful for the purpose I need. He also kindly gave me
some sample code for looking at fields and deciding a data score. This code
has set of a brain wave for me..(highly unusal) and I would like to know if
my thoughts are realistic.
The current code relies on the validation rules being very much down to me
to keep updated. I.e. Now some keeps entering "Not important" for address_1.
From the code I could just add it under case_1 but it would ne nice if the
validation checks were in some way maintanable by the users who will
eventually use the database.
Therefore, I have a database which uses a switchboard method of menues..i.e.
switchboard items. Could I use this method within my database; So instead
of switchboard items, I would have fault items and the case values would be
looking for an item?
Public Function DataScore( _
ByVal RecordID As Long) _
As Integer
'ByVal RecordID As Long 'Primary key of record
Dim CurrentRecord As Recordset 'Record identified _
by RecordID key value
Dim fldField As Field 'One of the data fields
'Grab the selected record
Set CurrentRecord = CurrentDb.OpenRecordset _
("SELECT * FROM [ContactList] " _
& "WHERE [ContactList_ID] = " _
& RecordID & ";", _
dbOpenSnapshot)
'Start by assuming all fields to be valid
DataScore = CurrentRecord.Fields.Count
For Each fldField In CurrentRecord.Fields
'Look for whatever might be wrong in the field
Select Case fldField.Name
Case "Contact Name"
If Right$(fldField.Value, 5) = "troyd" _
Then DataScore = DataScore - 1
If UCase$(Left$(fldField.Value, 1)) = "X" _
Then DataScore = DataScore - 1
Case "Address 1"
If InStr(fldField.Value, "Baker") > 0 _
Then DataScore = DataScore - 1
Case "Post Code"
If Left$(fldField.Value, 3) = "2V5" _
Then DataScore = DataScore - 1
End Select 'Case fldField.Name
Next fldField
End Function 'DataScore()