Field1 controls what is displayed in Field2

C

cpocpo

Hello,

I asked this awhile back, but am still unsure of what to do:

Is there anyway to have the Field2 automatically entered in the table
when the value for Field1 is selected in the combo box on the form??

In other words, on the form, select "Paperclip" using a combobox which
is tied to Field1. In the next field2 is a listbox (or combo,
whichever works) that would change to say "Part 06207". (It would be
grayed out so no data entry happens there by the user.)

Select "Stapler" in Field1 and field2 changes to "Part 099A"

etc.

??

BTW, is there a site somewhere where we can share Access files so that
I can just modify someone else's format, or they can modify mine
instead of reinventing the wheel everytime??

Appreciate all the good info!

V/R

LostGuy
 
G

Guest

Hi,

One way you can do it is like this:

In your combo box query make sure that one column contains the information
you want to display in your text box. Remember the column number (just count
the columns). Since Access starts counting the columns with 0 do the same to
get your column number. Let's say it is 1 (the 2nd column).

Then use your combo box's AfterUpdate Event in VBA. Add this code to the sub.

Me.mytextboxname = Me.mycomboboxname.Column(1)

Your sub should look like this:

Private Sub mycomboboxname_AfterUpdate()
Me.mytextboxname = Me.mycomboboxname.Column(1)
End Sub

Also add this code Me.mytextboxname = Me.mycomboboxname.Column(1) to the
Form's Current Event.

That should do it.

Or you can use this method:
http://www.microsoft.com/downloads/...A1-3C4E-4371-81E4-F9347B7A1DD7&displaylang=en
 
G

Guest

It's me again.

To make your textbox unable to be changed by someone else open your form in
design view, open the Properties sheet, click the Data tab, and change Locked
from No to Yes. That's it.

You will be able to see what is in the text box but it cannot be edited.

Hunter57
Just huntin' for some data.
http://churchmanagementsoftware.googlepages.com
 
J

John W. Vinson

Hello,

I asked this awhile back, but am still unsure of what to do:

Is there anyway to have the Field2 automatically entered in the table
when the value for Field1 is selected in the combo box on the form??

Yes; but in a properly designed database it should almost NEVER be necessary
to do so. A field should depend only on the Primary Key of its table; here
you're talking about two fields which depend upon each other.
In other words, on the form, select "Paperclip" using a combobox which
is tied to Field1. In the next field2 is a listbox (or combo,
whichever works) that would change to say "Part 06207". (It would be
grayed out so no data entry happens there by the user.)

Select "Stapler" in Field1 and field2 changes to "Part 099A"

Why not simply use a Combo Box based on a Parts table? Store the part number
in the table when you select Stapler or Paperclip from the combo. If you wish,
you can *DISPLAY* (without storing) the part name in a textbox: set its
control source to

=cboPartNumber.Column(1)

to display the second (it's zero based) column of the combo's row source
query.
BTW, is there a site somewhere where we can share Access files so that
I can just modify someone else's format, or they can modify mine
instead of reinventing the wheel everytime??

Jeff Conrad's resources page:
http://www.accessmvp.com/JConrad/accessjunkie/resources.html

The Access Web resources page:
http://www.mvps.org/access/resources/index.html

John W. Vinson [MVP]
 

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