Using command Buttons

N

Nick T

Hi,

I wonder if anyone can help with the following:
(i'v pasted my thread below).

Thanks.



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
 
J

Jeff Boyce

Nick

There's something I'm not understanding.

It sounds like you want to force your users to click on multiple command
buttons to enter digits in a text control.

Why not just have them type the digits into the control?

What am I missing?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
F

fredg

Hi,

I wonder if anyone can help with the following:
(i'v pasted my thread below).

Thanks.

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

I don't want to say that this is a strange request, but .... this is a
strange request.

I suppose you could code a button's click event:
[ControlA] = [ControlA] & "5"

Click the button 3 times and the field will contain "555" as a string.
 
P

Pete D.

I guess if you really wanted to do this you could grab Terry kraft's
calculator form from Access WEB and modify it according to active control to
place results in that box. Developer handbook also has one that is simple
to use.

http://www.mvps.org/access/resources/downloads.htm#C

fredg said:
Hi,

I wonder if anyone can help with the following:
(i'v pasted my thread below).

Thanks.

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

I don't want to say that this is a strange request, but .... this is a
strange request.

I suppose you could code a button's click event:
[ControlA] = [ControlA] & "5"

Click the button 3 times and the field will contain "555" as a string.
 
R

Rastro

Yeah. If you want it user friendly I think It will be better to let them
type.

I imagine that you need some kind of numeric pad to click several times and
construct what?
An string with phone number?
Whatever you need, in that case, it will require to set when you are going
to start recording the string for the textbox and when to stop and set the
value to the textbox.
Clear the variable and start again.

It can be done with an extra command button which will set the textbox and
two public variables.

In declarations paste this:
Dim strTextBoxName, strTextRecord as String

Add a command button and name it btnSetText and paste this In the click
event routine:
if strTextRecord="" then exit sub
Controls(strTextBoxName).SetFocus
Controls(strTextBoxName) = strTextRecord
strTextRecord=""


And in the rest of 10 buttons replace the code that I gave to you before for
this one:
If Screen.PreviousControl.ControlType = 109 Then strTextBoxName =
Screen.PreviousControl.Name
strTextRecord = strTextRecord & ActiveControl.Caption

Hope it helps

Rastro
 
P

Pete D.

I should add that if this is for disabled you might look into voice control
which works pretty good with numbers. Gets expensive for good text/word
recognition althought technology is getting much better for the cost.

Pete D. said:
I guess if you really wanted to do this you could grab Terry kraft's
calculator form from Access WEB and modify it according to active control
to place results in that box. Developer handbook also has one that is
simple to use.

http://www.mvps.org/access/resources/downloads.htm#C

fredg said:
Hi,

I wonder if anyone can help with the following:
(i'v pasted my thread below).

Thanks.

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

:

If it helps put this code in each button click event:

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.

I don't want to say that this is a strange request, but .... this is a
strange request.

I suppose you could code a button's click event:
[ControlA] = [ControlA] & "5"

Click the button 3 times and the field will contain "555" as a string.
 
R

Rastro

I forgot something:
The process is this:
select the textbox (eg. textbox1) then click 1, 4, 7, 2, whatever button,
and then click btnSetText and you'll see
"1472whatever button" in the textbox1.

After this you should select other textbox or the textbox1 text will be
replaced with the new text.
 
N

Nick T

Hi All,

Thanks for the help, slowly getting there i think.
Im using command buttons as the database shall be used on a wireless
touchscreen PC (like a Samsung Q1) - i dont want users to have the opertunity
to touch 'keyboard' buttons - more likelyhood for operator error etc!

Many thanks & may be in touch for more help!

Nick

Pete D. said:
I should add that if this is for disabled you might look into voice control
which works pretty good with numbers. Gets expensive for good text/word
recognition althought technology is getting much better for the cost.

Pete D. said:
I guess if you really wanted to do this you could grab Terry kraft's
calculator form from Access WEB and modify it according to active control
to place results in that box. Developer handbook also has one that is
simple to use.

http://www.mvps.org/access/resources/downloads.htm#C

fredg said:
On Tue, 13 May 2008 15:29:01 -0700, Nick T wrote:

Hi,

I wonder if anyone can help with the following:
(i'v pasted my thread below).

Thanks.

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

:

If it helps put this code in each button click event:

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.


I don't want to say that this is a strange request, but .... this is a
strange request.

I suppose you could code a button's click event:
[ControlA] = [ControlA] & "5"

Click the button 3 times and the field will contain "555" as a string.
 
N

Nick T

Hi,
This is frustrating me now - wish i never started!!
Hope you can help again.......

What do you mean by pasting the code in 'declarations' what are these &
where do i paste the code you have suggested?

Thanks
Nick
 
R

Rastro

Don't worry.

The declarations section in every module (a form is a class module) is in
the top.
By default access adds a declaration in every module: "Option Compare
Database".
Here you declare variables (or whatever) that you want to keep reachable to
the whole module (Public Variables)
In the other side you declare it private when you create it inside of a
private procedure like:
Private Sub Button_Click()
Dim MyVariable as String
End sub
What ever value that MyVariable has it can't be read outside of the private
sub section.

So, paste it right below the "Option Compare Database" at the top of the
module

Dim strTextBoxName, strTextRecord as String

Then follow the rest of the instructions.

Rastro
 

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