Please use actual table and field names as well as error messages.
It looks like your TrailerDesc field contains a table name. Which line generates the error? What happens when you set a breakpoint and step through your code?
Duane Hookom MVP
MS Access
To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Wed, 1 Oct 2014 10:54:08 -0700
Subject: [MS_AccessPros] Re: Dlookup Criteria
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
It looks like your TrailerDesc field contains a table name. Which line generates the error? What happens when you set a breakpoint and step through your code?
Duane Hookom MVP
MS Access
To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Wed, 1 Oct 2014 10:54:08 -0700
Subject: [MS_AccessPros] Re: Dlookup Criteria
John,
I'm trying to use that as part of a filename in a transfer spreadsheet. Here is the code:
Dim stDocName As String
Dim MyForm As Form
stDocName = DLookup("TrailerDesc", "TempVIN")
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acTable, stDocName, True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"qryExportTempVIN", "S:\Licensing\" & Format(Date, "yyyy") & "\" & stDocName & _
".xls"
MsgBox _
"An Excel Spreadsheet has been created. It is S:\Licensing\TempVIN_mm_dd_yyyy.xls"
DoCmd.SelectObject acForm, MyForm.Name, False
Doyce---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
Doyce-
Are you assigning the results of the lookup to something? Maybe wrong data type?? What does your code look like?
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
(Paris, France)
On Oct 1, 2014, at 7:43 PM, winberry.doyce@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:Duane,
It actually shows the contents of the field I want which is the description of the trailer but I didn't think anyone would know what that meant so I substituted Trailer Description in my question.
Doyce
---In MS_Access_Professionals@yahoogroups.com, <duanehookom@...> wrote :Doyce,
I'm not sure why your error states "Trailer Description" when this is not in your DLookup("TrailerDesc", "TempVIN") . Are you getting confused by field captions?
Duane Hookom MVP
MS Access (2001-2014)
To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Wed, 1 Oct 2014 10:13:27 -0700
Subject: [MS_AccessPros] Dlookup Criteria
Hello Friends,
I'm trying to use DLookUp to return the value in a description field from a temp table where all records will have the same description in the field. Here is what I have DLookup("TrailerDesc", "TempVIN") but I don't know what to put in the criteria. Any record will do. There is a recordID which is the primary key. It is autonumber. I'm getting an error that says "My database cannot find the Trailer Description you referenced in the Object Name argument".
Doyce
__._,_.___
Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (6) |
.
__,_._,___
Tidak ada komentar:
Posting Komentar