Could anyone help with the below please???
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
"Al Campagna" wrote:
> 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."
>
>
> "Nick T" <Ni...@discussions.microsoft.com> wrote in message
> news:D88A379D-4254-4E33...@microsoft.com...
> > 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
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"Nick T" <Ni...@discussions.microsoft.com> wrote in message
news:9FFA805A-2538-4994...@microsoft.com...
Following an input into any of the text boxes whether it be text or number,
could i use the SetFocus function AfterUpdate??
Any suggestions or simply not possible??
Many thanks
If Not Screen.PreviousControl.ControlType = 109 Then Exit Sub
strTextBoxName = Screen.PreviousControl.Name
strButtonText = ActiveControl.Caption
strButtonName=ActiveControl.Name
Controls(strTextBoxName).SetFocus
Controls(strTextBoxName) = strButtonText
Controls(strButtonName).SetFocus
-------------------
This will check if the previous control was a textbox (109) and exit if not.
If yes then will put the strButtonText in the textbox that had the focus
when the button was clicked. This process means move the focus to the
textbox, set the value and return the focus to the button. The strButtonText
is the value that the button has and need to set in the text box.
"Nick T" <Ni...@discussions.microsoft.com> escribió en el mensaje de
noticias:ADDBD6D2-BD49-4653...@microsoft.com...
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