Dynamic If statement

The condition isn't on the field that holds the criteria... The conditions are on the fields that are described in the contents of the criteria field... Plus, the criteria can change (and often do)... I have it table driven right now so that a simple change to one table results in the criteria field being updated...
 
This approach should still work, initially you're examining the contents of one field to know which other fields need to be tested.
Can you post a couple of examples of what "are described in the contents of the criteria field"

David
 
I've changed my approach to how I'm doing this... Instead of deleting the records based the criteria, I'm now building the SQL string and running an Append aka Insert based on the criteria (which is all specified in a separate table)... This still gives me the flexibility of the criteria being potentially anything as long as it is specified in the table that drives it...
 
This is the code (except I didn't yet change it to actually execute the command):

Code:
    Set db = CurrentDb()
    Set rs = db.OpenRecordset("QARR Definitions - Eligible")
        
    DoCmd.SetWarnings False

    rs.MoveFirst
    
    Do While Not rs.EOF
        If rs.Fields("EligCrit") <> "All" And rs.Fields("EligCrit") <> "If Diabetes Screen" Then
            strSQL = "INSERT INTO [QARR Eligibility] SELECT [QARR Eligibility Step 1].* FROM [QARR Eligibility Step 1]" & _
                        "WHERE [QARR Measure] = """ & rs.Fields("QARR Measure") & """ And " & rs.Fields("EligCrit") & ";"
            MsgBox strSQL
        End If
        rs.MoveNext
        Loop
    
    DoCmd.SetWarnings True
 

Users who are viewing this thread

Back
Top Bottom