Using comand buttons to input data into text boxes

N

Nick T

Hi,
I have a database which uses command buttons to input numbers into a text
box all on one form.
I can currently use command buttons to do this, however for obvious reasons
as you will see by the code, the command button will only put a number into
one text box.
Current code:
Me.order = Me.order & "1"

This code for my command button 1 will put a "1" into my text box called
"order"

However, i want the same command button to be able to put the same
information into other text boxes as well.
Eg. what ever text box my cursor is in, i want the command button to put the
number in when clicked.
Any suggestions on the code i should use??

Many thanks
Nick
 
A

Al Campagna

Nick,
You wrote...
Me.order = Me.order & "1"
This code for my command button 1 will put a "1" into my text box called
"order"
Not really true. It appends a text 1 to whatever is already in Order.
However, i want the same command button to be able to put the same
information into other text boxes as well.
If that's true then using the Click event of your button...
Private Sub cmd1_Click()
SomeField1 = Field1 & "1"
SomeField2 = Field2 & "1"
SomeField3 = Field3 & "1"
' etc... for all fields
End Sub
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
N

Nick T

Hi,
Thanks for the help.
Your suggestion works, but not how i want it to.
Ill try explaining a little better:

I have 10 command buttons on a form and 20 text boxes. To make my system
user-friendly, i want a user to use the command buttons to input data into
the text boxes. The command buttons are labelled 1 to 10 and when clicked,
the command button will imput the relivant number into a text box.

I want the command buttons to put their number into only one text box at a
time, but this text box could be any of the 20 text boxes i have on my form.
So really, the command button needs to put its number into the text box which
has the cursor in it.

Hope this makes sense & any help is greatly appreciated.

Nick
 
N

Nick T

Hi,
Thanks for the great help - nearly there i think so hope you can help a
little more.

I have put the code into the command buttons code and it works as you say,
however, i have 10 command buttons which effectively i want to use to enter
any 'string' of numbers into a set text box. eg. if i want to write the
number 555 into a text box, then i want to click the no. 5 command button
three times.

Unfortunately, the code doesnt allow this, so hope you can help.

Lastly, once the correct number has been entered into the desired text box,
i shall have another command button next to it, which when clicked will
simply SetFocus to the next text box i want to input a 'string' of numbers
into.

Look forward to hearing from you.

Thanks
 

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