Rabu, 01 Oktober 2014

Re: [MS_AccessPros] Re: Dlookup Criteria

 

Hi Doyce,

try something like this:

'~~~
dim nRecordID as Long
dim sDesc as string

nRecordID = INSERT CODE HERE

sDesc  = nz(DLookup("TrailerDesc", "TempVIN", "recordID=" & nRecordID),"")

'~~~

WHERE
recordID is the name of your autonumber (or long integer) primary key field


What is the name of the temporary table?
What is the name of the field you want the value for?

Warm Regards,
Crystal

Graph with Access!
How to create a chart:and how to change it with VBA
http://www.youtube.com/watch?v=YhgNX6BWWmk&list=PLis0tV85b5t6TuFPTldPF-Ra67As6-Rj0

 *
   (: have an awesome day :)
 *



On Wednesday, October 1, 2014 12:30 PM, "Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:




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



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: Crystal <strive4peace2008@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (7)

.

__,_._,___

Tidak ada komentar:

Posting Komentar