I have a macro that I have been using for years and has continued to work through the various versions of excel. I recently upgraded to Windows 11 and it stopped working. Everything else associated with this macro has remained the same. When I try to use the macro I get an error that says: 'Component not correctly registered'. I've tried to find the source of the problem and it is probably something simple but I haven't had any luck. Below is the macro code I use. Any thoughts on what is happening?
Sub GetNFF()
Dim db As Database
Dim rs As Recordset
Dim dbLocation As String
Dim Sql As String
Dim PCode As String
Dim vAnew As String
Dim i As Integer
PCode = Cells(5, 1).Value
Sql = "SELECT ADDRESS.FILENO, ADDRESS.LOW, ADDRESS.HIGH, ADDRESS.DIRECTION, ADDRESS.STNAME, ADDRESS.STYPE, ADDRESS.OWNER, ADDRESS.STORIES, ADDRESS.NEEDEDFIRE, DETAIL.P, DETAIL.WARR FROM ADDRESS INNER JOIN DETAIL ON ADDRESS.FILENO = DETAIL.FILENO WHERE (((ADDRESS.NEEDEDFIRE) Is Not Null) AND (DETAIL.LINENO)='" & "001" & "') AND ((ADDRESS.PCODE)='" & PCode & "') AND ((Val([P]))<=8) ORDER BY Val(ADDRESS.NEEDEDFIRE) DESC;"
dbLocation = "C:\ISRBdata\SLCDATA.MDB"
Set db = DBEngine.Workspaces(0).OpenDatabase(dbLocation)
Set rs = db.OpenRecordset(Sql)
vAnew = Sheets("Page 2").Cells(7, 3).CopyFromRecordset(rs, 40)
For i = 0 To vAnew - 1
Cells(7 + i, 11).Value = Val(Cells(7 + i, 11).Value)
Cells(7 + i, 10).Value = Stories(Cells(7 + i, 10).Value)
Next
Sheets("Page 2").Activate
rs.Close
db.Close
End Sub
Sub GetNFF()
Dim db As Database
Dim rs As Recordset
Dim dbLocation As String
Dim Sql As String
Dim PCode As String
Dim vAnew As String
Dim i As Integer
PCode = Cells(5, 1).Value
Sql = "SELECT ADDRESS.FILENO, ADDRESS.LOW, ADDRESS.HIGH, ADDRESS.DIRECTION, ADDRESS.STNAME, ADDRESS.STYPE, ADDRESS.OWNER, ADDRESS.STORIES, ADDRESS.NEEDEDFIRE, DETAIL.P, DETAIL.WARR FROM ADDRESS INNER JOIN DETAIL ON ADDRESS.FILENO = DETAIL.FILENO WHERE (((ADDRESS.NEEDEDFIRE) Is Not Null) AND (DETAIL.LINENO)='" & "001" & "') AND ((ADDRESS.PCODE)='" & PCode & "') AND ((Val([P]))<=8) ORDER BY Val(ADDRESS.NEEDEDFIRE) DESC;"
dbLocation = "C:\ISRBdata\SLCDATA.MDB"
Set db = DBEngine.Workspaces(0).OpenDatabase(dbLocation)
Set rs = db.OpenRecordset(Sql)
vAnew = Sheets("Page 2").Cells(7, 3).CopyFromRecordset(rs, 40)
For i = 0 To vAnew - 1
Cells(7 + i, 11).Value = Val(Cells(7 + i, 11).Value)
Cells(7 + i, 10).Value = Stories(Cells(7 + i, 10).Value)
Next
Sheets("Page 2").Activate
rs.Close
db.Close
End Sub