Solved

Fill Access form data based on textbox

Posted on 2013-01-30
1
556 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
1 Comment
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now