?
Solved

Fill Access form data based on textbox

Posted on 2013-01-30
1
Medium Priority
?
624 Views
Last Modified: 2013-01-31
Hi all.

I have a form with 5 textboxes. The first textbox is for the product number. I want the end user to be able to enter a product number in the textbox and have the other 4 fields  to be automatically filled in.

How can I do this using VBA?
0
Comment
Question by:printmedia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 38837251
You can use a Recordset for this:

Dim rst As DAO.Recordset
Set rst = Currentdb.OpenRecordset("SELECT * FROM SomeTable WHERE ProductNumber='" & Me.ProductNumber & "'")

If Not (rst.EOF and rst.BOF) Then
   Me.Textbox1 = rst("Field1")
   Me.Textbox2 = rst("Field2")
   Etc etc
End If

Of course, if your form is BOUND (i.e. has a Recordsource) and your Controls are also Bound, then you could run into issues with this, if you update the values in BOUND textboxes.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question