Is there a way to make this work faster? (1 Viewer)

bjreb

Registered User.
Local time
Today, 11:03
Joined
May 7, 2001
Messages
37
I run this to look for images on the hard drive. If its there it updates the record to reflect that.

Function UpdateAvailaiblity()

Dim sMyFile As String
Dim vCheckimage As Variant
Dim sSql As String
Dim rs As DAO.Recordset


sSql = "SELECT dbo_TBL_HANDHELD_DATA.INT_PHOTO_ONE_AVAILABLE, dbo_TBL_HANDHELD_DATA.TXT_PHOTO_ONE_NAME " & _
"FROM dbo_TBL_HANDHELD_DATA INNER JOIN dbo_TBL_DISPLAY_DATA ON dbo_TBL_HANDHELD_DATA.TXT_DISPLAY_FULL_NAME = dbo_TBL_DISPLAY_DATA.TXT_DISPLAY_FULL_NAME " & _
"WHERE (((dbo_TBL_HANDHELD_DATA.DT_DATE_COMPLETED) Between #1/1/2008# And Now()) AND ((dbo_TBL_HANDHELD_DATA.IMG_PHOTO_ONE) Is Not Null) AND ((dbo_TBL_DISPLAY_DATA.TXT_BRAND_KEY) Like '045*'))"

Set rs = CurrentDb.OpenRecordset(sSql)

rs.MoveFirst

Do Until rs.EOF

sMyFile = rs.Fields(1)
vCheckimage = Dir(sMyFile)

If vCheckimage <> "" Then
rs.Edit
rs!INT_PHOTO_ONE_AVAILABLE = "2"
rs.Update
End If
If vCheckimage = "" Then
rs.Edit
rs!INT_PHOTO_ONE_AVAILABLE = "-1"
rs.Update
End If
rs.MoveNext
Loop

Set rs = Nothing





End Function


Let me know if it possible.

Thanks
Andy
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 11:03
Joined
Jul 9, 2003
Messages
16,271
>>> dbo_TBL_HANDHELD_DATA <<<<

This suggests to me that the code is from an SQL server database?
 

bjreb

Registered User.
Local time
Today, 11:03
Joined
May 7, 2001
Messages
37
Linked tables, just to lazy to change the names
 

Guus2005

AWF VIP
Local time
Today, 12:03
Joined
Jun 26, 2007
Messages
2,645
there is a query, a recordset and two updates on the recordset.

Do you want the query to be optimised, your code or the complete setup of the function?

I'd go for the latter
 

Users who are viewing this thread

Top Bottom