PC Review


Reply
Thread Tools Rate Thread

Autofill form from linked table

 
 
DMH
Guest
Posts: n/a
 
      23rd Apr 2009
I have a form (linked to a table) that I fill out any time a person enters my
facility. Is there any way to autofill the rest of the person's information
(text boxes in the same form) when I type their name in the corresponding
text box?
 
Reply With Quote
 
 
 
 
Arvin Meyer MVP
Guest
Posts: n/a
 
      23rd Apr 2009
It's not clear why you would want to do this. Are these people already in
your database? If so, picking/typing their name from a combo box along with
their PersonID key, should be sufficient, except perhaps for a date/time
field. If they have data that you want to print, create a report with a
query based upon their data.

If you are just populating the form for display purposes only, include the
additional information in columns in the combo. Then you can fill in other
text boxes by setting them = to the column (minus 1 because it's zero based)
So for instance, their phone number was the 4th column, you'd use a
controlsource in the text box like:

= cboComboBoxName.Column(3)

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"DMH" <(E-Mail Removed)> wrote in message
news:622B73FE-732F-4662-8D3A-(E-Mail Removed)...
>I have a form (linked to a table) that I fill out any time a person enters
>my
> facility. Is there any way to autofill the rest of the person's
> information
> (text boxes in the same form) when I type their name in the corresponding
> text box?



 
Reply With Quote
 
李建国
Guest
Posts: n/a
 
      23rd Apr 2009

"DMH" <(E-Mail Removed)> 写入消息
news:622B73FE-732F-4662-8D3A-(E-Mail Removed)...
>I have a form (linked to a table) that I fill out any time a person enters
>my
> facility. Is there any way to autofill the rest of the person's
> information
> (text boxes in the same form) when I type their name in the corresponding
> text box?


 
Reply With Quote
 
Ken Sheridan
Guest
Posts: n/a
 
      23rd Apr 2009
You should not store the name, nor any other attributes of the person in the
table underlying your form. Instead store a unique numerical ID, such as
PersonID. A number should be used because names can be duplicated, even in
quite small workgroups; the other attributes should not be stored because
they are already held in a separate 'People' table, so duplicating them
introduces redundancy, which puts the table at risk of inconsistent data
being entered. The primary key of the People table should also be a PersonID
number, and can conveniently be an autonumber, so if your People table
doesn't already have one just add an autonumber column and it will be
automatically filled with unique values. Note that the foreign key PersonID
column in the table underlying your form must not be an autonumber, though.

To show the other attributes of the person on your form make the form's
RecordSource a query which joins the tables on PersonID and includes all the
columns from the form's underlying table and those from people which you want
to show on the form. Don't include the PersonID column from People though,
only the foreign key PersonID column from the form's underlying table. You
can then include controls in the form bound to the columns from the people
table. Set the Enable property of these controls to false (No) and their
Locked property to True (Yes) to prevent them being updated.

On your form add a combo box bound to the foreign key PersonID column, set
up as follows:

ControlSource: PersonID

RowSource: SELECT PersonID, FirstName & " " & LastName FROM People ORDER
BY LastName, FirstName;

BoundColum: 1
ColumnCount: 2
ColumnWidths: 0cm;8cm

If your units of measurement are imperial rather than metric Access will
automatically convert the last one. The important thing is that the first
dimension is zero to hide the first column and that the second is at least as
wide as the combo box.

You can then simply select a person from the list and the controls on the
form bound to the columns from people will show the relevant values for the
selected person.

You can also enter a new person, i.e. one not currently represented in the
People table, by typing their name in the combo box. Code in the combo box's
NotInList event procedure then opens a form to add the new person to the
people table, passing the name you entered into the combo box to the form,
the returning you to the combo box with the new name added after you close
the People form. We can come back to how you do this later if you wish.

Ken Sheridan
Stafford, England

"DMH" wrote:

> I have a form (linked to a table) that I fill out any time a person enters my
> facility. Is there any way to autofill the rest of the person's information
> (text boxes in the same form) when I type their name in the corresponding
> text box?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why no autofill from table to form? Cruisinid Microsoft Access Forms 4 10th Sep 2008 12:56 PM
Form linked to Linked Excel Table via ComboBox ryguy7272 Microsoft Access VBA Modules 10 22nd Apr 2008 04:07 PM
autofill a table via form input mattsmom Microsoft Access 3 6th Dec 2007 10:12 PM
Form/Table AutoFill =?Utf-8?B?S25lcHB5?= Microsoft Access 1 13th Dec 2005 05:26 PM
Re: AutoFill a form with info from a table Jonathan Blitz Microsoft Access Form Coding 0 11th Mar 2004 09:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:11 AM.