Link to home
Start Free TrialLog in
Avatar of mtrussell
mtrussell

asked on

Loop within Select Case

I have a select Case that says (I have simplified it)

Select Case Category

Case "Criteria 1"

If IsNull(Me.Date1OP.Value) Then
Me.Date1OP.Value = Date
End If

End Select


What I need is that the code goes through the entire record set and updates the date to today's date all records where the Category is 'Criteria 1'.. how do I do this?
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

you can update all records using an update query


dim uSql as string
Select Case Category

 Case "Criteria 1"
     uSql="Update TableName set [Date1OP]=Date() where Category= 'Criteria 1'"

 Case "Criteria X"
     uSql="Update TableName set [Date1OP]=Date() where Category= 'Criteria X'"


 End Select

'update the records

currentdb.execute usql, dbfailonerror
Avatar of mtrussell
mtrussell

ASKER

It's close but this ignores the IF statement.  If there is a date already in the field I don't want to bulk update.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial