View Full Version : Acces and Excel Help


hewstone999
05-28-2008, 02:28 AM
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
05-28-2008, 02:54 AM
try:

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