|
|
Hi all,
Can anyone tell me why this codes doesn't work?
=DCount("[Status] = 'InStock'","Inventory Table","[Name] = 'hammer'")
I have this code on a textbox and it return all value that associate with hammers regardless of the status ( Sold/InStock), any suggestion?
Thank Mark
-- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1
|
|
DCount doesn't work that way. Try:
=DCount("*", "Inventory Table", "[Name] = 'hammer' And [Status] = 'InStock'")
Incidentally, Name is not a good choice for a field name. For a comprehensive lists of names to avoid (as well as a link to a free utility that will check your application for compliance), see what Allen Browne has at http://www.allenbrowne.com/AppIssueBadWord.html
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!)
"AnhCVL via AccessMonster.com" <u47640[ at ]uwe> wrote in message news:8dbab73eb329d[ at ]uwe...
[Quoted Text] > Hi all, > > Can anyone tell me why this codes doesn't work? > > =DCount("[Status] = 'InStock'","Inventory Table","[Name] = 'hammer'") > > I have this code on a textbox and it return all value that associate with > hammers regardless of the status ( Sold/InStock), any suggestion? > > Thank > Mark > > -- > Message posted via AccessMonster.com > http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1>
|
|
Hi Douglas,
Thanks for the quick response, I've tried your suggestion as:
=DCount("*", "Inventory Table", "[Tname] = 'hammer' And [Status] = 'InStock'")
the [Name] was [Tname], sorry for the typo, this resulted in "#Error", I had it on the page footer, I've also tried to put it under report footer but received the same error, any idea why?
Thanks Mark
Douglas J. Steele wrote:
[Quoted Text] >DCount doesn't work that way. Try: > >=DCount("*", "Inventory Table", "[Name] = 'hammer' And [Status] = >'InStock'") > >Incidentally, Name is not a good choice for a field name. For a >comprehensive lists of names to avoid (as well as a link to a free utility >that will check your application for compliance), see what Allen Browne has >at http://www.allenbrowne.com/AppIssueBadWord.html> >> Hi all, >> >[quoted text clipped - 7 lines] >> Thank >> Mark -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1
|
|
The only thing I can think of is to put square brackets around the table name since it contains spaces:
=DCount("*", "[Inventory Table]", "[Tname] = 'hammer' And [Status] ='InStock'")
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!)
"AnhCVL via AccessMonster.com" <u47640[ at ]uwe> wrote in message news:8dbc9738d0929[ at ]uwe...
[Quoted Text] > Hi Douglas, > > Thanks for the quick response, I've tried your suggestion as: > > =DCount("*", "Inventory Table", "[Tname] = 'hammer' And [Status] = > 'InStock'") > > the [Name] was [Tname], sorry for the typo, this resulted in "#Error", I > had > it on the page footer, I've also tried to put it under report footer but > received the same error, any idea why? > > Thanks > Mark > > > Douglas J. Steele wrote: >>DCount doesn't work that way. Try: >> >>=DCount("*", "Inventory Table", "[Name] = 'hammer' And [Status] = >>'InStock'") >> >>Incidentally, Name is not a good choice for a field name. For a >>comprehensive lists of names to avoid (as well as a link to a free utility >>that will check your application for compliance), see what Allen Browne >>has >>at http://www.allenbrowne.com/AppIssueBadWord.html>> >>> Hi all, >>> >>[quoted text clipped - 7 lines] >>> Thank >>> Mark > > -- > Message posted via AccessMonster.com > http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1>
|
|
I've tried but it shows same "#Error", I'll do some more research on it and will take it slow, if you come accross something similiar, please keep me update and if I'll find out and get it to work, I'll inform you. Thanks for all the suggestions Douglas.
Mark
Douglas J. Steele wrote:
[Quoted Text] >The only thing I can think of is to put square brackets around the table >name since it contains spaces: > >=DCount("*", "[Inventory Table]", "[Tname] = 'hammer' And [Status] >='InStock'") > >> Hi Douglas, >> >[quoted text clipped - 27 lines] >>>> Thank >>>> Mark
-- Message posted via http://www.accessmonster.com
|
|
One thing to verify is that Tname and Status are actually text fields. If you used the Lookup Wizard field for one or both of the fields, you find that the field doesn't actually contain what you think it does (This is but one of the many reasons why many of us abhor lookup fields: see http://www.mvps.org/access/lookupfields.htm at "The Access Web" for some others)
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!)
"AnhCVL via AccessMonster.com" <u47640[ at ]uwe> wrote in message news:8dc64e75bd015[ at ]uwe...
[Quoted Text] > I've tried but it shows same "#Error", I'll do some more research on it > and > will take it slow, if you come accross something similiar, please keep me > update and if I'll find out and get it to work, I'll inform you. Thanks > for > all the suggestions Douglas. > > Mark > > Douglas J. Steele wrote: >>The only thing I can think of is to put square brackets around the table >>name since it contains spaces: >> >>=DCount("*", "[Inventory Table]", "[Tname] = 'hammer' And [Status] >>='InStock'") >> >>> Hi Douglas, >>> >>[quoted text clipped - 27 lines] >>>>> Thank >>>>> Mark > > -- > Message posted via http://www.accessmonster.com>
|
|
Hi Douglas,
All the fields I am dealing with are text, I manually specified them and double checked them. Funny thing is that after I tried and played around with it, I got bored and decided to do try the same code from a fresh new report so I've created a new report, totally blank, drop a text box and employed the code, it work perfectly. The very same codes I place on the textbox on my existing report which I had lots of other information on there, showing "#Error", I am thinking spend a little time to move or recreate all the info from my other report to the new report. I first thought it was the trailing spaces and type and verified, retyped but wasn't the case. I copy and pasted the same codes which shown "#Error" on one from to the new form, it show me the correct number. it's weird isn't it? Thanks for all the helps Douglas.
Mark
Douglas J. Steele wrote:
[Quoted Text] >One thing to verify is that Tname and Status are actually text fields. If >you used the Lookup Wizard field for one or both of the fields, you find >that the field doesn't actually contain what you think it does (This is but >one of the many reasons why many of us abhor lookup fields: see > http://www.mvps.org/access/lookupfields.htm at "The Access Web" for some >others) > >> I've tried but it shows same "#Error", I'll do some more research on it >> and >[quoted text clipped - 16 lines] >>>>>> Thank >>>>>> Mark -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1
|
|
|