Solved

Fill Access form data based on textbox

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

863 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

23 Experts available now in Live!

Get 1:1 Help Now