Textbox to Textbox!! PLEASE HELP

C

chrislfc11

Ok so I have a form with information displayed in it from one of my tables in
the DB.
If I have two empty text boxes and I want to enter data in one textbox and
have it display in the other textbox on the same form.

Textbox 1 is called "test" and textbox 2 is called "test1".

So if I enter (hello) in "test" I want "test1" to also display (hello).
How do I do this???

Also lets say I have multiple textboxes and I enter information in one
textbox "test" how do I get the info to display in the other textboxes
"test1" "test2" "test3" etc...

Thanks
 
D

Douglas J. Steele

Sounds like an unusual requirement, but in the AfterUpdate event of the
first text box, put code to populate the second text box.

Private Sub Test_AfterUpdate()

Me.Test1 = Me.Test

End Sub

To do this for a number of text boxes, you can do something like:

Private Sub Test_AfterUpdate()
Dim intLoop As Integer

For intLoop = 1 To 5
Me.Controls("Test" & intLoop) = Me.Test
Next intLoop

End Sub

That assumes there are five text boxes Test1, Test2, Test3, Test4 and Test5,
and it will populate all five of them with the contents of text box Test.
 
C

chrislfc11

That worked Thank you.

My next questions is I created my form with a Wizard and then I clicked
Tabular view, which gives me many text boxes called "test1".

When I enter information in "test" it only updates the highlighted row with
"test1" in it. How Do I get it to update all rows on the form with a textbox
called "test1"??

Thanks
 
C

chrislfc11

OK I understand what your saying, but what if you dont know how many
textboxes your are going to have. Because we may be adding more data to the
database over time and it could go from 5 textboxes to 20 and the code will
only work for 5 of them.
Also all my textboxes are named test1 in different rows because they are in
the Tabular view from the Forms Wizard.

Does that make any sense?
 
D

Douglas J. Steele

Perhaps you should describe what you're trying to do.

As I mentioned earlier, your requirement is an unusual one, and not knowing
how many textboxes you're going to have on the form is even more unusual.

If you've got a continuous form (or a form in datasheet view) and test1 is
an unbound field, setting a value for test1 will apply to every row on the
form. It's only if test1 is bound to a field in the form's RecordSource that
setting a value will only apply to the one row.
 
R

Ron2006

Are those fields named "Test1" etc or rather "TeXt1" etc.

if the second then they are unbound text boxes and probably increment
by 2 at a time.

More information about what you are trying to do would be helpful.
 
C

chrislfc11

This is really hard to explain, but here goes.....

This is all for Hotels as I am creting a DB for specific information about
many hotels, the reason why I dont know how many textboxes there will be is
because we are constantly adding new hotels to the form or deleting them.

This form deals with versions of a given software program on the computers
in the hotels. lets say right now we are using version 1, but lets say next
week we update the hotels with version 2. I dont want to have to come into
the form and manualy enter version2 for each hotel in the list.
I wanted to type version 2 in a textbox and have it update all the textboxes
on the form from version 1 to version 2.

does that make sense?
 
C

chrislfc11

destination textboxes are called "test1".

The textbox in which i want to enter the info into is called "test".
 
D

Douglas J. Steele

It sounds to me as though you're going about it this wrong way.

Adding new hotels (or products or employees or whatever your application's
managing) should never require a change to the form!

From the cursory description you've given, I'd say you need three tables.
One will contain the details of each Hotel, and one will contain the details
of each piece of software you have. Now, since there's a many-to-many
relationship between Hotel and Software (each hotel uses many different
software applications, each software application is used by many hotels),
you need a third table to resolve that many-to-many.

To maintain this data, you'd need two forms, arranged as a form/subform. The
parent form would be bound to the Hotel table. The subform would be bound to
the intersection table (the third one mentioned above), with the
LinkParentFields/LinkChildFields linking on the Hotel identifier. On that
subform, you'd have a combo box using the Software table as its RowSource,
so that all that's necessary is to select from the list, not type.

For an example of what I'm talking about, take a look at the Northwinds
database that comes with Access. The data situation is the same as the
situation with Products and Orders: one order can contain many products, and
one product can appear on many orders. For that reason, the Order Details
table was introduced. The data is maintained by the Orders form, which has
the Orders Suubform as a subform on it.

Note, too, that it's not always necessary to use the form to do bulk
updates. If all your hotels are switching to version 2 of a particular piece
of software, you can always write a query to update the data in the
intersection table.
 
C

chrislfc11

I understand everything you just mentioned and I do have a table for the
hotels and this is a separate table with the hotels specific software and
version.

The reason for me doing everything in a form is that I am interning and will
be going back to school and the people here do not know how to work access
very well. They dont know how to create queries and so on. I was trying to
make it simple for them to come into a form and type in the new version
number and to hit enter and have all the hotel fields automatically update
for them.

So they dont have to worry about anything else other than opening Access
clicking the form and hitting enter to update the database.
I'm sure there is a better way to do this that I have done.......
 
B

Beetle

I agree. You definitely should not leave your inexperienced users with
the task of trying to create their own update query! So YOU should
create the query, and then have it run from the click event of a command
button, key press event of a text box, etc.
 
D

Douglas J. Steele

If you're not going to be around, all the more reason why you need to design
it correctly.

As Beetle suggests, create a form for the specific purpose of doing global
updates that runs the query for them.
 
C

carolinetu

I have a similar problem:

I have a tabular form where you choose a client number from a combo box
based on the client master file, and then enter various data for that client,
which is held in a separate table. I want to display the client name on the
form, which I am doing by looking it up from the client master table.
However, the form displays the first client name on each line, rather than
the correct one for each client. What am I doing wrong?
 
M

Marshall Barton

carolinetu said:
I have a similar problem:

I have a tabular form where you choose a client number from a combo box
based on the client master file, and then enter various data for that client,
which is held in a separate table. I want to display the client name on the
form, which I am doing by looking it up from the client master table.
However, the form displays the first client name on each line, rather than
the correct one for each client. What am I doing wrong?

Similar to what? ;-)

Change the combo box's row source query to include the
client name as well as the number. Be sure to adjust the
ColumnCount and ColumnWidths accordingly. Then your client
name text box can use an expression like
=cboClientNum.Column(N)
where N is the 0 based number of the column with the name.
 
C

carolinetu

That has the same effect - the client name appears in all lines. However I
have now solved the problem by joining the two tables in a query and using
that as the basis for the form, so each line picks up the client name from
the client master table. After selecting a new client, you just need to
requery, which I have done by coding it in the "after update" event for the
combo box.
 
M

Marshall Barton

That is the usual way to do it when the combo box is
unbound. For a bound combo box, I think it's easier/cleaner
to do what I suggested.
 

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