473,834 Members | 2,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query retrieving wrong data from text box?

23 New Member
Hi, all

I run into the same problem on Access 2000 and 2003.

Hopefully someone can replicate it – or not.

1. Create an unbound form – call it Form1.

2. Insert two unbound text boxes – call it Text0 and Text2.

3. Run the form and enter some data in both text boxes.

4. While the form is still loaded, create a query that retrieves the data from these text boxes.
The query’s statements in design view must be:
Expr1: [Forms]![Form1]![Text0]
and
Expr2: [Forms]![Form1]![Text2]

5. Run the query (it should retrieve the data you entered into the two text boxes).

6. Now go back to the form in design view and change the format of Text2 to “Short Date” (or any other format you like).

7. Run the form and enter some new data in both text boxes.

8. While the form is still loaded, run the query.

9. Now the query’s Expr2 returns garble, while Expr1 still works fine. (It also does not help to change Text2’s format back to something else).

The same problem occurs if I use “[Forms]![FormName]![ControlName]” to retrieve data from a bound text box - if it is bound to a field which is formatted as “Short Date” or “Long Date”. But I do not get an error if the text box is bound to a field which is formatted as text.

Any advice?
Feb 27 '07 #1
10 3796
MMcCarthy
14,534 Recognized Expert Moderator MVP
I can't see how you can retrieve data from an unbound control in the on load event of the form.
Feb 27 '07 #2
Gerhard
23 New Member
No, the query need not be in the on load event. You can add a command button to run the query after you entered data into the text boxes.
Feb 27 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
No, the query need not be in the on load event. You can add a command button to run the query after you entered data into the text boxes.
Post the SQL of the query you are running.

To run a query based on the values in a textbox on a form the form must be open.

Mary
Feb 28 '07 #4
Gerhard
23 New Member
OK, let me try again, this time with the query being run from the open form itself.

1. Create an unbound form – call it Form1.

2. Insert two unbound text boxes – call it Text0 and Text2.

3. Create a query, which will retrieve the data from these text boxes.
The query’s statements in design view must be:
Expr1: [Forms]![Form1]![Text0]
and
Expr2: [Forms]![Form1]![Text2]

The query's sql will be:
SELECT Forms!Form1!Tex t0 AS Expr1, Forms!Form1!Tex t2 AS Expr2;

5. Now Insert a command button on the form that runs the above query in its on click event.

6. Run the form and enter some data in both text boxes.

7. Click the command button to run the query (it should work perfectly and retrieve the data you entered into the two text boxes).

8. Now go back to design view and change the format of Text2 to “Short Date” (or any other format you like).

9. Run the form again and enter some new data in both text boxes.

10. Run the query.

11. This time the query’s Expr2 returns garble, while Expr1 still works fine.
Feb 28 '07 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT [Forms]![Form1]![Text0] AS Expr1, Format([Forms]![Form1]![Text2], "mm/dd/yyyy") AS Expr2;
Feb 28 '07 #6
Gerhard
23 New Member
Thank you ya beauty! It works.

But tell me, why is it necessary to specify the format in the query if you use “[Forms]![FormName]![ControlName]"?
Feb 28 '07 #7
MMcCarthy
14,534 Recognized Expert Moderator MVP
Thank you ya beauty! It works.

But tell me, why is it necessary to specify the format in the query if you use “[Forms]![FormName]![ControlName]"?
Because you are dealing with unbound controls. There is no where to get the format from. Formating the textbox only works for the data while it's in the textbox.

Mary
Feb 28 '07 #8
Gerhard
23 New Member
Clever Irish. And they can play rugby too!
Feb 28 '07 #9
MMcCarthy
14,534 Recognized Expert Moderator MVP
Clever Irish. And they can play rugby too!
We sure can, especially when we're playing the English - LOL
Feb 28 '07 #10

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

Similar topics

3
1744
by: Quentin Huo | last post by:
Hi: If I have a query string for retrieving data from SQL Server database, is there a way to transfer it to a query string for retrieving data from Oracle or any other database like mySQL...? I mean by a program. I am working on C#. Thanks Q.
1
1204
by: antonyliu2002 | last post by:
This message was originally a follow-up in a thread, but it went ignored and I do want some help so I am initiating it as a new topic. After Patrick and Karl showed me some examples, I was trying to retain user data across multiple pages using the Context facility. On page1.aspx, I have Page1 | Page2 |
5
2239
by: aniket_sp | last post by:
i am using a data adapter and a dataset for filling and retrieving data into .mdb database. following is the code..... for the form load event Dim dc(0) As DataColumn Try If OleDbConnection1.State = ConnectionState.Closed Then OleDbConnection1.Open() Else
7
1145
by: John | last post by:
After reading the tutorial from http://www.startvbdotnet.com/ado/msaccess.aspx I wrote this code in an attempt to get information from my MDB file called FillMe. The only table in that Access file is called MainTable; Imports System.Data.OleDb Public Class Form2 Inherits System.Windows.Forms.Form Dim cn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader
5
5249
by: AdrianG | last post by:
I am trying to write a single SQL query that would retrieve the data that I need. For example, I have a table called Athletes that has 2 fields: name and sport containing the name of an athlete and the sports that he or she participates in. Some sample data: John,hockey Michael,football John,swimming Eric,swimming Michael,baseball
16
3528
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for renaming the duplicate records? My thinking was to take the results of the duplicate query, and somehow have it number each line where there is a duplicate (tried a groups query, but "count" won't work), then do an update query to change the duplicate to...
10
2725
by: darkenroyce | last post by:
Hi Guys I am creating a sports database and one of the features involves create drop down dialogue boxes that retrieve data from MySQL tables and provides them as <option> within <select></select>. I am using PHP for this and I'm fairly new at the programming language. I have got the dialogue to work with respect to retrieving the data from MySQL table but it only displays the data from first row/first column of the table twice. I want the...
34
2597
by: vpriya6 | last post by:
Hi guys, I am new to Ajax, xml and javascript. I want to know how can I retrieve data from xml and display in the html page? please help me out. suppose my xml file is customer.xml the code is below: <CUSTOMER>
6
4413
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one field between them. The join field in both tables are indexed and I'm selecting 1 field from each table to lookup. The Access query is taking more than 60 second to retrieve 1 record and if I execute the same query within the Query Analyzer, it...
0
9796
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
9643
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
10544
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
6951
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
5624
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4425
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
3973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3079
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.