473,383 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to Create Selective Autofill TextBoxes

2
Hey guys, I am new to Access and am wondering how one might go about programing a form that will auto-fill information into a TextBox when a specific record is selected from a ComboBox, but when no record is selected allow me to put in new information.

I am designing a database that tracks contracts between medical institutions (facilities) and a university. Some facilities have the same contract information because they are owned by the same parent company, while others have no parent company, therefore unique information. I'd like to be able to have the contract information from facilities, who have the same contract information, to be auto-filled by selecting a value from a ComboBox that lists all of the parent companies, but still have the ability to input new information myself for facilities who have no parent.

I have tried using If Then Else statements with no success. If anyone has an idea of how I should go about creating this it would be very much appreciated as I have reached the the limits of my knowledge about Access.
Oct 28 '11 #1

✓ answered by NeoPa

On your form you could have a ComboBox (We'll call [cboParent]) and a TextBox (We'll call [txtContract]).

[txtContract] might start, by design, as unlocked and empty. [cboParent] would need to have a list of parent companies and associated contract information, as well as an entry reflecting no parent (where the contract information part would be blank). Assume for now, that the the entry for no parent company holds the string value "None".

In the AfterUpdate event procedure of [cboParent] place the contract information (using the Column() method) into [txtContract]. Next compare the value of [cboParent] with "None" and set the .Locked property of [txtContract] based on that.

The code would be similar to :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboParent_AfterUpdate()
  2.     With Me
  3.         .txtContract = .cboParent.Column(Index:=1)
  4.         .txtContract.Locked = (.cboParent <> "None")
  5.     End With
  6. End Sub

3 2200
NeoPa
32,556 Expert Mod 16PB
On your form you could have a ComboBox (We'll call [cboParent]) and a TextBox (We'll call [txtContract]).

[txtContract] might start, by design, as unlocked and empty. [cboParent] would need to have a list of parent companies and associated contract information, as well as an entry reflecting no parent (where the contract information part would be blank). Assume for now, that the the entry for no parent company holds the string value "None".

In the AfterUpdate event procedure of [cboParent] place the contract information (using the Column() method) into [txtContract]. Next compare the value of [cboParent] with "None" and set the .Locked property of [txtContract] based on that.

The code would be similar to :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboParent_AfterUpdate()
  2.     With Me
  3.         .txtContract = .cboParent.Column(Index:=1)
  4.         .txtContract.Locked = (.cboParent <> "None")
  5.     End With
  6. End Sub
Oct 28 '11 #2
BioDev
2
Thanks NeoPa! I have been stuck on that one for awhile.
Oct 31 '11 #3
NeoPa
32,556 Expert Mod 16PB
Pleased to help :-)
Nov 1 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Richard Price | last post by:
Hope someone can help. I am trying to write a php script that will create a text file with dynamic fields in it,save the page and then mail it as an attachment. To be more precise I want the...
1
by: Dave | last post by:
Hi All, Just getting started with ASP (NOT .NET) and have a question: I have a basic form and I'm trying to add some functionality to it. I want a user to be able to select a product from a...
2
by: Karen Sullivan | last post by:
Hi, all. I'm fairly new to SQL, and I have been trying to create a table from a text file. I have been looking at this for days, and can't find the problem. I get a syntax error " Line 55:...
2
by: Darin Browne | last post by:
I have to create a fixed length text file and was hoping someone could point me to an example or resources that could help explain how it is done in C#. Thanks.
1
by: Thilo Frank | last post by:
I want to add a flashing text cursor to my selfmade user control. Is there an existing class availible for this problem or do I have to write a thread, which flashs the cursor? THX for your help...
3
by: Peter | last post by:
Hello! Please, could you tell me, is it possible to create and stream for example a text file to the browser so that the file is not stored anywhere on a hard drive? User click's a link, eg....
1
by: kapilsharma26 | last post by:
Dear friends, I have to create a webpage where in it ask the user to enter a number. when the user enters a number and clicks Submit button, then page should display that number of text boxes. ...
3
by: Wolfgang Meister | last post by:
I would like to append text to a file which might exist or not. What is the easiest way to open or create it depending if it exists or not and to set it into an "append" text mode?
16
by: dybalabj | last post by:
I realize this should probably be a simple solution, but I have only been learning PHP and MySQL for a couple weeks. I am attempting to write an invoicing system that uses a MySQL database to store...
0
menayah
by: menayah | last post by:
Hi all, How to create a Scrolling Text or a ticker in VB.NET 2.0 Web Forms?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.