Given the code below how would I code this so that if the select query "MGW6Store - Acc Select" has no records my macro would just continue on with out stopping with a run=time error box?
Thanks David
Function MGWacc()
Dim MyDB As Database
Dim MySet As Recordset
Dim I As Integer
Dim R As Integer
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MySet = MyDB.OpenRecordset("select * from [MGW6Store - Acc Select] order by [Acc%Sales] DESC", DB_OPEN_DYNASET)
MySet.MoveLast
I = MySet.RecordCount
R = 12
If MySet.RecordCount > 0 Then
MySet.MoveFirst
For I = 1 To MySet.RecordCount
MySet.Edit
MySet![Acc Rank] = (R - 2)
MySet.Update
MySet.MoveNext
R = R - 2
Next
End If
End Function
Thanks David
Function MGWacc()
Dim MyDB As Database
Dim MySet As Recordset
Dim I As Integer
Dim R As Integer
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MySet = MyDB.OpenRecordset("select * from [MGW6Store - Acc Select] order by [Acc%Sales] DESC", DB_OPEN_DYNASET)
MySet.MoveLast
I = MySet.RecordCount
R = 12
If MySet.RecordCount > 0 Then
MySet.MoveFirst
For I = 1 To MySet.RecordCount
MySet.Edit
MySet![Acc Rank] = (R - 2)
MySet.Update
MySet.MoveNext
R = R - 2
Next
End If
End Function