473,324 Members | 2,313 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,324 software developers and data experts.

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 1439
You cannot put an SQL statement into the Control Source of a text box.

Save the query.

Then use:
=DLookup("CashAcct", "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*******@iname.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.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("CashAcct", "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*******@iname.comwrote
>You cannot put an SQL statement
into the Control Source of a text box.

Save the query.

Then use:
=DLookup("CashAcct", "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
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...
6
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...
6
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...
2
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...
10
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...
3
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...
6
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,...
20
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...
9
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.