473,805 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query Works By Itself, But Not in a Control

Greetings,

I have a simple query (Access 2000 on W2kPro):
SELECT [tblBankInfo].[CashAcct]
FROM tblBankInfo INNER JOIN tblPartnerships ON
[tblBankInfo].[AcctNumber]=[tblPartnerships].[AcctNumber]
WHERE [tblPartnerships].[PshpID]=[Forms]![frmTransMain]![PshpID];

which runs fine by itself. However, when I put it into ControlSource of
a text box on a report (enclosed in brackets, without a semicolon at
the end, and with = preceding), the control displays #Error?

The name of the control is txtCashAcct; the frmTransMain is open and
has a valid PshpID selected. No functions in the control, only the SQL
quoted above. What doesn't it like?

Thanks,
Yisroel

Jul 24 '06 #1
3 1460
You cannot put an SQL statement into the Control Source of a text box.

Save the query.

Then use:
=DLookup("CashA cct", "Query1")
replacing Query1 with the name of your query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<ey*******@inam e.comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
Greetings,

I have a simple query (Access 2000 on W2kPro):
SELECT [tblBankInfo].[CashAcct]
FROM tblBankInfo INNER JOIN tblPartnerships ON
[tblBankInfo].[AcctNumber]=[tblPartnerships].[AcctNumber]
WHERE [tblPartnerships].[PshpID]=[Forms]![frmTransMain]![PshpID];

which runs fine by itself. However, when I put it into ControlSource of
a text box on a report (enclosed in brackets, without a semicolon at
the end, and with = preceding), the control displays #Error?

The name of the control is txtCashAcct; the frmTransMain is open and
has a valid PshpID selected. No functions in the control, only the SQL
quoted above. What doesn't it like?

Thanks,
Yisroel

Jul 24 '06 #2
Allen Browne wrote:
You cannot put an SQL statement into the Control Source of a text box.

Save the query.

Then use:
=DLookup("CashA cct", "Query1")
replacing Query1 with the name of your query.
Aha! Then the statement in Help and a book on Access I have -- "any
valid Access expression can be a control data source" -- needs
qualification: "unless it's an SQL expression."

Thank you very much, Allen. This works beautifully.

Yisroel

Jul 24 '06 #3
<ey*******@inam e.comwrote
>You cannot put an SQL statement
into the Control Source of a text box.

Save the query.

Then use:
=DLookup("CashA cct", "Query1")
replacing Query1 with the name of your query.

Aha! Then the statement in Help and a
book on Access I have -- "any valid
Access expression can be a control data
source" -- needs qualification: "unless
it's an SQL expression."
SQL is not an "Access expression."

Larry Linson
Microsoft Access MVP
Jul 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
3073
by: Robert Brown | last post by:
suppose I have the following table: CREATE TABLE (int level, color varchar, length int, width int, height int) It has the following rows 1, "RED", 8, 10, 12 2, NULL, NULL, NULL, 20 3, NULL, 9, 82, 25
6
3265
by: Nicolae Fieraru | last post by:
Hi All, I was trying to update a field in a table, based on the results from a query. The table to be updated is tblCustomers and the query is qrySelect. This query has two parameters, provided by a form. I created an update query called qryUpdate, which has both tblCustomers and qrySelect (linked by CustomerID). And I try to update one of the fields in tblCustomers. If I open the form, and I click on a button, I can open qrySelect and...
6
1694
by: Liz Malcolm | last post by:
Hello and Thanks in advance for any help. I am using Access 2000. I have a data entry form that opens a main form (using the On Click event of the combo box ) with tab controls and 1 subform on the last tab control. The main form is opened using a where clause to restrict the contact type. The subform is built on a separate table that lists other contact types that the contact could be a member of. Example a volunteer could also be a...
2
1443
by: John Hoge | last post by:
I'm looking for that elusive .net time saving magic. I have an application that presents a list of items which the user can select from. A CheckBoxList works great for that, but I want to query a database based on their selections. I'm forced to dynamically building a SQL statement in a method I could have done easily in classic ASP: SELECT fields FROM tablename WHERE ID IN (value1,value2....)
10
3282
by: Daniel | last post by:
In Microsoft Access I can write a query that includes the criteria: Between Date()-7 And Date() to retrieve the records from a table that fall within the last week. I'm trying to write a procedure to do this in VB.NET (2005 Express Edition). But I always get the message that the Jet database engine does not recognize the syntax (of the Date function I assume). I've also tried Now() and it works but only by itself. I seem to add or
3
3817
by: Kevin M | last post by:
I have one table and have created a form from that table. Also, I have created a delete query. I want to but a button on the form which will delete all records from the table; however, I cannot get anything to work. I know this is probably simple for more experienced Access users. Any help would be greatly appreciated. Thanks Kevin
6
3736
by: nbomike | last post by:
I am trying to integrate a custom page into a shopping cart app written in PHP. The custom page is basically a part finder widget that helps customers find a car part based on the car's make, model, year, etc. This custom page has a form that submits the page to itself. It does this because I have four drop down menus, and the data in each following drop down is dependent on the previous selection. Since there was so much data, I didn't want to...
20
2914
by: raylopez99 | last post by:
Inspired by Chapter 8 of Albahari's excellent C#3.0 in a Nutshell (this book is amazing, you must get it if you have to buy but one C# book) as well as Appendix A of Jon Skeet's book, I am going through some LINQ queries. But how to cast? ( See the below, modified from somebody else's code. The problem is the query 'stops' (throws a cast exception) at "3", and never gets to "violet".
9
8088
by: dizzydangler | last post by:
Hi, all! After receiving a lot of help from ADezzi, Msquared, and NeoPa getting my ms access 2007 db functioning, I've run into another hitch that I haven't been able to solve. The database itself is saved on a MS Sharepoint server, and I would like users to be able to access it and execute the search query in read-only mode. In its current configuration, the query only "works" when the file is opened in "Edit" mode, and I've already had some...
0
9716
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10105
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4323
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3845
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.