470,632 Members | 1,441 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,632 developers. It's quick & easy.

Calculated Form Field, with Criteria?

4 2Bits
Hi all, I have a form with a few Listboxes on it that acts as my Main Menu if you will.

I created separate queries for each list box with one field to count all the records in that list box.

Works great until one of the Listboxes is empty, then the form goes blank.

Can I create a calculated field on my form that has criteria - IE: like I have in my qrys.

Below is the source code of my Main Menu form, which includes the individual queries I made. (I couldn't attach an image)

I would like to have a field that counts each section, "In Bound", "Out Bound", etc.

Thanks in advance!
Scott
Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2.    Count(tblArrivals.Status) AS CountOfStatus
  3. FROM 
  4.    STATUS 
  5.        INNER JOIN tblArrivals ON STATUS.STATUS = tblArrivals.Status
  6. WHERE 
  7.     (
  8.       ((STATUS.STATUS) Like "Arriving within 24 Hours") 
  9.         AND 
  10.       ((tblArrivals.VSLTYPE) Not Like "Y/M")
  11.     );
3 Weeks Ago #1
1 10466
zmbd
5,444 Expert Mod 4TB
[BLUF]
So, I've read this question about a dozen times now and I'm not entirely sure what you are after - I don't think you need a calculated field for what you want - but it's hard to decern for certain from your post.

However, a fatal character flaw is that I dislike is not offering some possible answer - feels a bit dismissive and I never liked that when I asked for help
(sort of like when people say to RTFM or similar non-solution-answers - 👾🔺)

Using a generic database, attached, I've made a few aggregate queries that group on and count within tbl_people - see if this is what you are after... I'm fairly certain that it is...

Details:
+ qry_count_mf is based on a criteria within tbl_people

+ I also created a tbl_CrossReference that creates a many(to)many (M:M)(*) relationship between tbl_people and tbl_wordlist so as to have the innerjoin
++ qry_count_CrossRefInnerJoinWord
++ __qry_GUI_CrossReference is a more human readable form for tbl_CrossReference.
+++
One thing that strikes me is ((STATUS.STATUS) Like "Arriving within 24 Hours")
Ideally you would not be using a text string like this, better to use a normalized approach - this is what I am trying to show you with the tbl_CrossReference (*)

(*)-- now you could have something MUCH simpler such as the foreign key directly in tbl_people that relates back to tbl_wordlist (creating a 1:M relationship) instead of tbl_CrossReference
One advantage of using the related table (and the whole point of a relational database) is say I want to change the spelling of the word "color" from the American spelling to "colour" which is more common in other countries - I only need find that entry in the related table, change the spelling there - the primary key will not change; hence, I do not need to go back into potentially dozens (or thousands) of lines of SQL nor VBA to change a hard coded value "color" to "colour" as these would utilize the primary key

IF possible try posting your screen shot again
If you click on [Edit] for your original post it should default to the advanced editor and there is an [Upload Files] button
- when posting within a thread click on [advanced] in the advanced editor you can upload the image
- if you're still having issues uploading the image file please PM/DM me and we'll go from there
Attached Files
File Type: zip Bytesthread_977258.zip (100.1 KB, 4 views)
3 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Chris | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.