Acces and Excel Help (1 Viewer)

hewstone999

Registered User.
Local time
Yesterday, 17:53
Joined
Feb 27, 2008
Messages
37
I’m currently using vba in access to export values to an Excel Spreadsheet. I have this query below but I cant seem to export the value the SQL statement gives to the correct field in the spreadsheet.

n = 2
temp01 = xlSheet.Range("F" & n).Value
temp02 = xlSheet.Range("B" & n).Value

sql1 = "Select IFF_name from IFF_Descriptions Where IFF_Description = “ & temp02

temp01 = sql1
 

ecawilkinson

Registered User.
Local time
Today, 01:53
Joined
Jan 25, 2005
Messages
112
try:
Code:
n = 2
temp01 = xlSheet.Range("F" & n).Value
temp02 = xlSheet.Range("B" & n).Value 

'if IFF_description is a  numeric field
temp01 = dlookup("IFF_name", "IFF_Descriptions","IFF_description =" & temp02)
' if IFF_description  is a text field
temp01 = dlookup("IFF_name", "IFF_Descriptions","IFF_description = '" & temp02 & "'")

xlSheet.Range("F" & n).Value = temp01
(In case you cannot work out exactly what I've done, in the 2nd alternative I have added single quotes to surround the variable).

HTH,
Chris
 

Users who are viewing this thread

Top Bottom