Defaulting Form fields upon entry

C

Carey G

Can I make other fields autofill information from another table upon entering information in one field on the form?
Example: One table holds property information address, seller, phone numbers, etc. A form created to log showings for this property has a drop down for address and this form reports to a seperate table. Once a user selects the property address, can I make the remaining fields in that form autofill the required information for that specfic property?
 
D

Douglas J. Steele

Add the additional fields to the query upon which the combo box is based.
(It's not necessary to display them in the combo box). Then, in the combo
box's AfterUpdate event, put code to move those fields in your text boxes.

Something like

Me.txtAddress = Me.cboProperty.Column(3)

if Address is the fourth field in the query (Columns starting numbering at
0)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Carey G said:
Can I make other fields autofill information from another table upon
entering information in one field on the form?
Example: One table holds property information address, seller, phone
numbers, etc. A form created to log showings for this property has a drop
down for address and this form reports to a seperate table. Once a user
selects the property address, can I make the remaining fields in that form
autofill the required information for that specfic property?
 
C

Carey G

Thanks for your imput!!!!!!!!! But I'm to thick to completely understand your response :

So to better explain (for me probably than for you!

Table one (listings) holds all the information about a property, address, names, telephone numbers, etc and a form to input the information to that table.
Table 2 (offers) stores information about offers and has it's own form. In the offers table & form, a lot of the information is the same as the information in the listings table. The offers form is set up with a drop down (combo) box for the address of properties we have listed and gets the drop down information from the field / column in the listings table. NO Queries
Upon selection of a property address in the offers form...I want the remaining offer form to autofill from fields in the listings table. ie: names, telephone numbers, etc

Since there is no query, where would I input the example you gave me
And how would that develop the relationship to other text boxes/fields in the form

I kind of understand the track you were on (after event) but the query thing and dropping the fields in the query confused me???? and I don't understand how that creates the tie to the other fields/text boxes within the form?

Thank you for responding you did spark more thought!

Thanks Carey
 
D

Douglas J. Steele

I always prefer using Queries as the basis of combo boxes, since you can
control the order of the records.

Create a query on table 1 that lists all of the fields of the table in which
you're interested. Make sure it returns what you want, sorted in the correct
order. For the sake of argument, let's assume that the 1st field is the Id,
the 2nd is the Address, the 3rd is the name and the 4th is the telephone
number. (I'm assuming table 2 has a field that points to the Id of the
record in table 1)

Now, open your form in Design mode. Select the combo box (which I'm going to
assume is named cboProperties) and look at its properties. Presumably its
Row Source Type property is set to Table/Query. Change the Row Source
property to the name of the query you just saved above. Still looking at the
properties of the combo box, set the Column Count property to what ever is
correct (4 in my example above), set the Column Widths property to 0;2;0;0
(I'm assuming you're using inches: if not, you may have to play with that
value of 2 until it's a reasonable width.)

Now, find After Update event property associated with your combo box. Select
[Event Procedure] for its property, and click on the ellipsis (...) to the
right of the field. That will take you into the VB Editor.

Assuming you have a field named txtName, and one named txtTelephone on your
form, add the following code:

Private Sub cboProperties_AfterUpdate

Me.txtName = Me.cboProperties.Column(2)
Me.txtTelephone = Me.cboProperties.Column(3)

End Sub

Hope this helps.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Carey G said:
Thanks for your imput!!!!!!!!! But I'm to thick to completely understand your response :(

So to better explain (for me probably than for you!)

Table one (listings) holds all the information about a property, address,
names, telephone numbers, etc and a form to input the information to that
table.
Table 2 (offers) stores information about offers and has it's own form. In
the offers table & form, a lot of the information is the same as the
information in the listings table. The offers form is set up with a drop
down (combo) box for the address of properties we have listed and gets the
drop down information from the field / column in the listings table. NO
Queries!
Upon selection of a property address in the offers form...I want the
remaining offer form to autofill from fields in the listings table. ie:
names, telephone numbers, etc.
Since there is no query, where would I input the example you gave me?
And how would that develop the relationship to other text boxes/fields in the form?

I kind of understand the track you were on (after event) but the query
thing and dropping the fields in the query confused me???? and I don't
understand how that creates the tie to the other fields/text boxes within
the form??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top