Solved

Fill Access form data based on textbox

Posted on 2013-01-30
1
608 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 84

Accepted Solution

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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 …
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

749 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