Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 20th, 2007, 02:13 AM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ultimateace
Default calculated control box with iff

I am having problems with a iff statement.

I need to display a value from a table not connected to the form in control box. (brandname) based on the another textbox (brandid) the brandname is stored in a seperate table from the id that i will be using to reference it. but the complicated part is there is a chance that there may be no brandid. my solution was this

in the control source... =iff(isnull(brandid),"no brand",dlookup("brandname","brand","[brandid] = "& brandid.value))

but it doesn't work
the dlookup part works except where there is no brandid then there is an error message. i just need the no brand to appear when no brand is given... other than having a default value set to no brand on the table.... that would complicate much more..


 
Old January 22nd, 2007, 08:31 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This is a design issue (I spelled it right that time!)

You should have a Brand table:

tblBrand
BrandID - PK
BrandName - Text

Then use the combo box to select the BrandName (since that is the significant value) and the table will store the BrandID. When you need the BrandName in a report, it will automatically be there.

There is NO case where you should have a BrandName without a BrandID.

HTH

mmcdonal
 
Old January 23rd, 2007, 05:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

MMcDonal is correct. If BrandID is the primary key, it should never be null. If BrandID is not the primary key, then this may work; however, one questions why you're not searching using a primary key.

=Nz(DLookup("[BrandName]","Brand","[BrandID] = " & BrandID.Value), "No Brand")


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old January 23rd, 2007, 08:40 PM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ultimateace
Default

Thank you,
   And it was a stupid error sorry.. after posting it i figured it out. It was in fact what you said it is always usefull to use the iif statement instead of the iff statement :D. Thanks for the help and next time im working so late and can't figure the problem out I will just sleep on it :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating VBA calculated Text Box throught Report wintermute Access VBA 2 March 28th, 2008 12:00 PM
IFF () in SQL ayazhoda Access 5 July 17th, 2007 05:52 AM
IFF statement in SQL [email protected] SQL Server 2000 1 January 15th, 2007 01:13 PM
Would this be a IFF then Statement Corey Access 7 November 2nd, 2006 03:18 PM
Calculated control on report penta Access 2 June 13th, 2005 06:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.