473,797 Members | 2,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding text boxes to fields in a query

Hello, all -

I want to get a customer name, address and so forth from a customer table
using either a SELECT statement in a VBA procedure or in a query. The user
should be able to put a customer number in a text box and I'd like the
information to pop up in text boxes on a form.

Is it possible to bind text boxes to, say, the fields containing the
CustName and CustAddress in a query? I want to use text boxes for
appearance; I don't care for the look of combo boxes or subforms.

I've fiddled with this far too long, without success. Any suggestions?

Thanks in advance.
Steve E.

Nov 12 '05 #1
1 6164
> I want to get a customer name, address and so forth from a customer table
using either a SELECT statement in a VBA procedure or in a query. The user
should be able to put a customer number in a text box and I'd like the
information to pop up in text boxes on a form.

Is it possible to bind text boxes to, say, the fields containing the
CustName and CustAddress in a query? I want to use text boxes for
appearance; I don't care for the look of combo boxes or subforms.

I've fiddled with this far too long, without success. Any suggestions?


Sure. Just set the form's RecordSource property to a query that returns all of
the relevant fields (including the customer number, of course) and then place
textboxes bound to those fields that you want to display on the form. Then place
an unbound textbox/combobox on the form (named "txtFind" in the following
example) and insert code similar to the following in the unbound
textbox/combobox's "AfterUpdat e" event procedure:

'***Access 2000, or later
With Me.Recordset
'If the customer number field is a number
.FindFirst "CustomerNumber =" & Me.txtFind

'If the customer number field is text
'.FindFirst "CustomerNumber =""" & Me.txtFind & """"
End With
'***

'***Any version of Access
Dim rst As Object
Set rst = Me.RecordsetClo ne
'The following line assumes the customer number field is text
rst.FindFirst "CustomerNumber =""" & Me.txtFind & """"
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
Else
MsgBox "The specified customer was not found.", _
vbOKOnly + vbInformation
End If
'***

Although a text box will work, it might be more productive using a combo box to
help ensure entry of an existing value.

--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.o rg (See the Access FAQ at http://www.mvps.org/access)
NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<
Nov 12 '05 #2

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

Similar topics

1
2157
by: Serious_Practitioner | last post by:
This is such a simple problem. I've asked for, and gotten, help with this in the past, and I can't make this work. Once more, please - I want to be able to put a member number (which is the primary key of a table called tblMemberInfo) into a text box on an unbound form and get back, in some other text boxes, other information (name, e-mail address and date of birth, say) from the same table. I also want to get, from a table called...
2
2744
by: Lyn | last post by:
Hi, How do you bind the output columns from a UNION query when the fields from the two tables have different names? Consider this query (WHERE clauses omitted)... SELECT SurnameBirth, FNameBirth, DOB, 'Birth' from tblBirth UNION SELECT SurnameAlias, FNameAlias, #1/1/100#, 'Alias' from tblAlias; What I am doing here is searching two tables for a person where the name given may be the person's original name (at birth) or subsequent...
3
3251
by: Marnie | last post by:
Hi there I am new to VB.Net (formerly a Centura 'Gupta' programmer) and just trying to do a simple excercise out of the help to populate a couple of text fields on a form by using a parameterized query. ie. Walkthrough 'Displaying Data in a Windows Form Using a Parameterized Query Sounds simple but for some reason when I get to the step where you are supposed to 'Expand the (DataBindings) node, and for the Text property, expand DsAuthors1,...
19
2348
by: Simon Verona | last post by:
I'm not sure if I'm going down the correct route... I have a class which exposes a number of properties of an object (in this case the object represents a customer). Can I then use this object to databind to text boxes etc? I can't use a dataset as the object has loads of derived logic, for example updating one property may actually update several database fields for example.
11
5937
by: Dixie | last post by:
How can I programatically, take some Date/Time fields present in a table in the current database and change their type to text? dixie
11
3897
by: DP | last post by:
hi, i have a films table and form. i have a txt field in teh form called txtSearch , and i;ve created a query with all the film table fields in it. how can i get the query to load up, wth the required film infromation in it?? i've a query called qryFilmQuery
1
6435
by: Peter | last post by:
Hi, I'm trying to create a form that shows table rows in a listbox. Several comboboxes expand the foreign key fields into text values from the parent tables, and there are also some textboxes for the non-foreign key fields. When the user clicks on a row in the listbox, the comboboxes' SelectedItem changes to reflect the foreign key selections in the currently selected row. That part is working fine. I also want the textboxes to change to...
3
2447
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When the users selects an item from the combo box I'd like the 4 text boxes to get populated with the corresponding item information from the same dataset table row that the combo box is pulling it's info from. Is there an easy way of doing this besides...
4
2302
by: Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ | last post by:
I have created a report. This report needs to display records between two dates entered by the user. I put two text boxes on the report so I can enter the start and end date - I set them to use an input mask of 'short date' format. The problem is that when I enter anything in these text boxes, as soon as the field looses focus, the text is cleared out - thus the text box is left blank. I have a button on the form that calls the requery...
0
10468
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10245
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10021
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
9063
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7559
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6802
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
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4131
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
3
2933
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.