By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,140 Members | 1,301 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,140 IT Pros & Developers. It's quick & easy.

Simple screen keyboard for Access.

P: 44
Hi all;
Quick question for you - is there any way of building my own on-screen keyboard onto a form? My VB isn't so good so any simple solutions would be great! The Windows keyboard isn't viable, there's too many buttons and I need to be able to modify the layout.

Any ideas?

Feb 8 '09 #1
Share this Question
Share on Google+
6 Replies

Expert Mod 15k+
P: 31,419
You could create a form with various Command Button controls - each of which represents one of the characters you want to make available on your keyboard.

Unfortunately, you would have to handle the focus manually, as clicking on any of them changes it to that Command Button.

Alternatively, if you made them all Label controls instead, you might have an easier ride.

Welcome to Bytes!
Feb 8 '09 #2

P: 44
Thanks for the quick reply - I've been experimenting a little in the meantime. I've managed to set the value of a text box using a simple On Click event of

me!Name = me!command1.caption.

So if you click the button with A on it then A appears in the name box. I can see a way forward but typing in me!command???.caption for each and every letter will drive me nuts! There must be a more elegant solution! What about a piece of form-level code, where a click on one of the keyboard buttons sends its caption as a variable for the form-level procedure to apply? Can this be done?
Feb 8 '09 #3

P: 44
Right, I've had a bit more success. I can now copy the same little macro to every button which invokes a module, below:
Expand|Select|Wrap|Line Numbers
  1. Forms!frmValues!Name.SetFocus
  2. SendKeys Screen.PreviousControl.Caption
Should be simple, yes? Well the problem is that every time the focus moves to the Name field I imagine it gets highlighted too. And we all know what happens if you highlight a bit of text them press a key - it gets overwritten rather than appended to. Any ideas on how to remove the highlighting and send the cursor to the end of the string before sending the keystroke?
Feb 8 '09 #4

Expert Mod 15k+
P: 31,419
In that case you may want to map out an area (grid) of your form and use the MouseDown event of your form.

Unfortunately, Label controls take the MouseDown event rather than the form if they are there.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_MouseDown(Button As Integer, _
  2.                            Shift As Integer, _
  3.                            X As Single, _
  4.                            Y As Single)
  6. End Sub
Feb 8 '09 #5

P: 44
Thanks for all the info, I worked out a solution a few minutes ago!

Here's the module, it's run from a macro attached to the OnClick event of each button:

Forms!frmValues!Name.SetFocus 'sets the focus to the text box
Forms!frmValues!Name.SelStart = 0 'un-highlights text box, cursor to LHS
SendKeys "({end})" 'moves the cursor over to the RHS of any existing text
SendKeys Screen.PreviousControl.Caption '"Types" the caption of the command button used to invoke the code.

So happily if the command buttons are captioned Q W E R T Y then that's exactly what appears in the text box. SelStart was the command I was looking for, nothing else worked to un-highlight the damn text after SetFocus did its job!

Thanks for the help!

Feb 8 '09 #6

Expert Mod 15k+
P: 31,419
I would call a procedure from all instead personally...
But also use code to add the value (Caption) to the end of the Name control instead of using SendKeys.
Expand|Select|Wrap|Line Numbers
  1. Call Me.Name.SetFocus
  2. Me.Name.Caption = Me.Name.Caption & Screen.PreviousControl.Caption
NB. As this is a label (I assume - for a TextBox it would be either .Text or .Value) it won't take the focus anyway.
Feb 8 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.