Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2007

Tip: Looking for answers? Try searching our database.

lookup value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
peljo - 13 May 2007 17:38 GMT
In my form i want to lookup a field in the query and multiply this to the
value of a control.I get however errors.is it possible to do what i am doing :

Dim NewUnitprice As Double
set NewUnitPrice = " CCur(Nz(DLookUp("NewUnitPrice";"qryAmount";"OrderID=" &
[Orders].[OrderID]);0))"

Me!extendedprice = NewUnitprice

Where is the error in my code ?
Thank you in advance
tina - 13 May 2007 17:57 GMT
[Orders].[OrderID]

if OrderID is a field in the RecordSource of the form from which the code is
running, then just refer to it as OrderID, as

CCur(Nz(DLookUp("NewUnitPrice";"qryAmount";"OrderID=" _
   & OrderID);0))

if OrderID is in a different form, that form must be open when the code runs
(whether or not it is Visible), and you must use the full form reference, as

CCur(Nz(DLookUp("NewUnitPrice";"qryAmount";"OrderID=" _
   & Forms!FormName!OrderID);0))

replace FormName with the correct name of the form that the field is in, of
course. the current syntax (in both examples above) is referring to OrderID
as a Number data type. if it is a Text data type instead, then surround the
value with single quotes, as

CCur(Nz(DLookUp("NewUnitPrice";"qryAmount";"OrderID='" _
   & Forms!FormName!OrderID & "'");0))

also, you need to get rid of the double quotes surrounding the expression,
as

set NewUnitPrice = CCur(Nz(DLookUp("NewUnitPrice"; _
   "qryAmount";"OrderID='" & Forms!FormName!OrderID & "'");0))

and finally, i'm assuming that the use of semi-colons is appropriate for
your copy of Access. in the US (English?) version of Access, those
semi-colons would be replaced with commas.

hth

> In my form i want to lookup a field in the query and multiply this to the
> value of a control.I get however errors.is it possible to do what i am doing :
[quoted text clipped - 7 lines]
> Where is the error in my code ?
> Thank you in advance
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.