473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

SQL doesn't recognize a Form Control

Hi Everyone,

I have a form with several unbound search controls in the header. I have two queries to get the row sources for two of those controls (combo boxes). Both of these queries reference other controls in the same form with an IIF statement to determine which records to pull.

One of the queries is working and the other is not. It returns an error "...does not recognize 'Forms!IMT!Dept' as a valid field name or expression."

Here are the two queries:

WORKING:
Expand|Select|Wrap|Line Numbers
  1. SELECT department
  2. FROM ideas
  3. WHERE IIf(Forms!IMT!Care=True,([ideas].department) Like "CC*",([ideas].department) Like "*")
  4. GROUP BY ([ideas].department);
  5.  
NOT WORKING:
Expand|Select|Wrap|Line Numbers
  1. SELECT TEAMS
  2. FROM qryEmpGroups
  3.  
  4. WHERE IIf(Forms!IMT!Dept IS NULL, [qryEmpGroups].[TEAMS] LIKE "*",[qryEmpGroups].[DEPTS] = Forms!IMT!Dept )
  5. AND ((qryEmpGroups.TEAMS) Not Like "*exchange*" And (qryEmpGroups.TEAMS) Not Like "*leave*")
  6.  
  7. GROUP BY (qryEmpGroups.[TEAMS])
  8. ORDER BY (qryEmpGroups.[TEAMS]);
I tried removing the 2nd reference to the Dept control ("[qryEmpGroups].[DEPTS] = Forms!IMT!Dept") and replaced it with a string value, and still got the error. So it's originating from the first instance; the condition of the IIF statement.

I tried replacing the control name Dept with the control name Care and it still didn't work... the error then said it didn't recognize 'Care'.

I don't think it's relevant but qryEmpGroups is a query, where ideas is a table. I may have spoken too soon when I said this. As an experiment, I saved the results of qryEmpGroups to a table and referenced that instead of the query. It's unstable but as long as Dept is null, I'm getting results in the Teams combo box. :/


I'm stumped! What am I missing?
Mar 7 '16 #1

✓ answered by webbeacon


6 1102
NeoPa
32,556 Expert Mod 16PB
Try putting square brackets ([]) around the form references.

EG.
Expand|Select|Wrap|Line Numbers
  1. [Forms]![IMT]![Dept]
Mar 8 '16 #2
Hey NeoPa,

It's related to the crosstab query... I now have this code working flawlessly, but only when it's pointing to a table. Pointing to the query the table is derived from, I get that error again.

Expand|Select|Wrap|Line Numbers
  1. SELECT TEAMS
  2. FROM tblEmpGroups
  3. WHERE IIf([Forms]![IMT]![Dept] like "*",[tblEmpGroups].[department] like "*" & [Forms]![IMT]![Dept] & "*", [tblEmpGroups].[TEAMS] LIKE "*")
  4. AND ((tblEmpGroups.TEAMS) Not Like "*exchange*" And (tblEmpGroups.TEAMS) Not Like "*leave*")
  5. GROUP BY (tblEmpGroups.[TEAMS])
  6. ORDER BY (tblEmpGroups.[TEAMS]);
  7.  
Any thoughts? It's not the end of the world if i have to work from a table... I'm thinking I can build a "make table" into an onLoad event or something like that. Just an extra step I'd rather not have to include.
Mar 8 '16 #3
Just found the answer... https://support.microsoft.com/en-us/kb/209778
Mar 8 '16 #4
NeoPa
32,556 Expert Mod 16PB
We don't normally assign a post from the OP as Best Answer, especially if it's a link, but in this case the answer's a perfect fit so I have done.
Mar 9 '16 #5
haha thank you :) For future reference, would a more descriptive answer followed by the link be more appropriate?
Mar 15 '16 #6
NeoPa
32,556 Expert Mod 16PB
Simple question - Simple answer.

Yes.
Mar 16 '16 #7

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

Similar topics

1
by: Siddhartha Jain | last post by:
Hi Guys, I have three projects under one solution and I am referencing two projects to use them under the third one. The way I do it is I go to add references and then to the projects tab and add...
1
by: DU | last post by:
Assuming you have a typical form built in this manner: <form action="..."> <p><input id="idInputText" name="nameInputText" type="text" size="20"></p> <p><input id="idCheckbox"...
5
by: Brian Rypstra | last post by:
Does any one know if there exists a form control that can function much like a rectangle control but is circular (or 6 sided say)? Can I make a custom control called circle that groups 6 instances...
2
by: Softwaremaker | last post by:
Hi all, I have created a Windows Form control that runs on a web form. This control is a composite control comprising of other textboxes (public scope). This control inherits from the...
3
by: | last post by:
For a given web form, I want to know what the +simplest+ way to add an attribute to all of a particular control type on that page. For example, I might want to add an onClick attribute to all...
2
by: Shane | last post by:
I have this code that resizes a form control. i want to be about to do something like that in .net. the other version is in vb 6... here is the code Dim hgt As Single hgt = ScaleHeight -...
0
by: aakash | last post by:
Hello Guys I am upsizing ms access project to give it a ms sql connectivity I am having problem in accessing form control values in ms sql function CREATE FUNCTION "ReportList DateRange"() ...
17
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I get the value of a form control? -----------------------------------------------------------------------...
1
by: KMEscherich | last post by:
Using Access '97 Hi there, I have a form in which I am attempting to have a form control be hidden unless the CONTROL 1 = OTHER. This control is tied to a DROP-DOWN list and one of the options to...
2
by: Bhuwan Bhaskar | last post by:
Hi, I am new to asp.net. I want to know that, HTML and Web form control can work in same way example, using "runat = Server" attribute, html control can also executed at server, then what is the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.