We have a winner.
The code below ran and gave me this message:
"
Query took 53 seconds to return 58025 rows.
View took 1 seconds to return 58025 rows.
"
Thanks again for your input. I've put my vb & SQL below;
Code
-------------------
Private Sub TEST()
Dim dStrt As Date
Dim dEnd As Date
Dim sMsg As String
Dim rsdata As Recordset
' Start timer
dStrt = Now
' open recordset using local query with linked tables
Set rsdata = currentdb.OpenRecordset("SELECT * FROM qryVisitorLog") ' WHERE [Arrival_Date] = #26-jan-2004#")
' make sure we get a sensible recordcount
rsdata.MoveLast: rsdata.MoveFirst
' stop timer
dEnd = Now
' build message with results
sMsg = "Query took " & DateDiff("S", dStrt, dEnd) & " seconds to return " & rsdata.RecordCount & " rows." & vbCrLf & vbCrLf
'Close recordset
rsdata.Close
'NEXT test
' Start timer
dStrt = Now
Set rsdata = currentdb.OpenRecordset("SELECT * FROM vw_VisitorLog") ' WHERE [Arrival_Date] = #26-jan-2004#")
' make sure we get a sensible recordcount
rsdata.MoveLast: rsdata.MoveFirst
dEnd = Now
sMsg = sMsg & "View took " & DateDiff("S", dStrt, dEnd) & " seconds to return " & rsdata.RecordCount & " rows." & vbCrLf & vbCrLf
rsdata.Close
MsgBox sMsg
If Not rsdata Is Nothing Then Set rsdata = Nothing
End Sub
-------------------
[SQL]
CREATE VIEW dbo.vw_VisitorLog
AS
SELECT dbo.tblVisitorIdentity.LastName + ', '
dbo.tblVisitorIdentity.FirstName AS Name,
dbo.tblVisitorIdentity.CompanyName,
dbo.tblVisitorIdentity.Car_Registration_Number
dbo.tblVisitorIdentity.TimeExpected AS Due,
VisBuild.Building_Name,
Host.Name + Host.location + ' (' + Host.ext + ') ' AS HostName,
dbo.tblVisitorIdentity.Parking, dbo.tblVisitorIdentity.RoomBookingID
dbo.tblVisitorIdentity.Arrival_Date,
dbo.tblVisitorIdentity.VisiterID,
dbo.vw_MeetingRoomLocation.Short_Code,
VisBuild.Building_Code,
dbo.tblVisitorIdentity.TimeIn AS [in],
dbo.tblVisitorIdentity.TimeOut AS out,
dbo.tblVisitorIdentity.HostID,
dbo.tblVisitorIdentity.Memo,
dbo.tblVisitorIdentity.BuildingID,
dbo.tblVisitorIdentity.PassExpiryDate,
Contact.FirstName + ' ' + Contact.LastName + ' ('
RIGHT(Contact.Telephone, 4)
+ ')' AS ToContact,
dbo.tblVisitorIdentity.IDCardNo
FROM dbo.vw_Person Host RIGHT OUTER JOIN
dbo.tblVisitorIdentity ON Host.Employee_ID
dbo.tblVisitorIdentity.HostID LEFT OUTER JOIN
dbo.tblBuilding VisBuild O
dbo.tblVisitorIdentity.BuildingID = VisBuild.Building_ID LEFT OUTE
JOIN
dbo.tblRoomRequest O
dbo.tblVisitorIdentity.RoomBookingID = dbo.tblRoomRequest.Booking_I
LEFT OUTER JOIN
dbo.vw_MeetingRoomLocation O
dbo.tblRoomRequest.Booking_ID = dbo.vw_MeetingRoomLocation.Booking_I
LEFT OUTER JOIN
dbo.tblGeneralUsers Contact O
dbo.tblVisitorIdentity.Contact = Contact.Employee_ID
[/SQL]
The Access query:
[SQL]
SELECT [tblVisitorIdentity].[LastName] & ", "
[tblVisitorIdentity].[FirstName] AS Name
tblVisitorIdentity.CompanyName
tblVisitorIdentity.Car_Registration_Number
tblVisitorIdentity.TimeExpected AS Due, tblBuilding_1.Building_Name
[tblGeneralUsers].[FirstName] & " " & [tblGeneralUsers].[LastName] & "
" & [tblBuilding].[Building_Code] & [tblSide].[Side_Code]
[tblFloor].[Floor_Code] & " (" & Right([tblGeneralUsers].[Telephone],4
& ")" AS Host, tblVisitorIdentity.Parking
tblVisitorIdentity.RoomBookingID, tblVisitorIdentity.Arrival_Date
tblVisitorIdentity.VisiterID, qryMeetingRoomLocation.Short_Code
tblBuilding_1.Building_Code, tblVisitorIdentity.TimeIn AS [in]
tblVisitorIdentity.TimeOut AS out, tblVisitorIdentity.HostID
tblVisitorIdentity.Memo, tblVisitorIdentity.BuildingID
tblVisitorIdentity.PassExpiryDate, [contact].[FirstName] & " "
[contact].[LastName] & " (" & Right([contact].[telephone],4) & ")" A
ToContact, tblVisitorIdentity.IDCardNo
FROM tblGeneralUsers AS Contact RIGHT JOIN (((tblBuilding A
tblBuilding_1 RIGHT JOIN ((((tblBuilding RIGHT JOIN tblGeneralUsers O
tblBuilding.Building_ID = tblGeneralUsers.Building_ID) LEFT JOIN
tblSide ON tblGeneralUsers.Side_ID = tblSide.Side_ID) LEFT JOIN
tblFloor ON tblGeneralUsers.Floor_ID = tblFloor.Floor_ID) RIGHT JOIN
tblVisitorIdentity ON tblGeneralUsers.Employee_ID =
tblVisitorIdentity.HostID) ON tblBuilding_1.Building_ID =
tblVisitorIdentity.BuildingID) LEFT JOIN tblRoomRequest ON
tblVisitorIdentity.RoomBookingID = tblRoomRequest.Booking_ID) LEFT JOIN
qryMeetingRoomLocation ON tblRoomRequest.Booking_ID =
qryMeetingRoomLocation.Booking_ID) ON Contact.Employee_ID =
tblVisitorIdentity.Contact
ORDER BY [tblGeneralUsers].[FirstName] & " " &
[tblGeneralUsers].[LastName] & ", " & [tblBuilding].[Building_Code] &
[tblSide].[Side_Code] & [tblFloor].[Floor_Code] & " (" &
Right([tblGeneralUsers].[Telephone],4) & ")",
qryMeetingRoomLocation.Short_Code;
[/SQL]