Form with button that acts like the Symbol Keyboard in Words

SweetBabie

Registered User.
Local time
Yesterday, 17:28
Joined
Mar 26, 2010
Messages
13
I am not to sure if this is possible or not… I have search a lot and come up with nothing…
I want to basically add a Vietnamese language keyboard on to the form with button where I can just push and add the text into the text line I am currently at. Just like Microsoft Words with Symbol. I take the database around and use on different computers and would not like to dl the Vietnamese program on the computers.
Thanks for the Help in advance.

Kristine
 
Create the keyboard as a form and add it to the main form as a subform.

Each key is a button with code that adds the desired character to the textbox on the main form. I would suggest storing the character to be sent in the Tag property of the button and reuse the same code to apply the tag to the target textbox.

The name of the current textbox is held as a variable so that the keyboard form knows which textbox is currently receiving entries.
 
GalaxiomAtHome,

I'm still very new with this..

Is their away I can just creat a form and not use a subform?

What kind of code would I need to enter? Tag property?

Thanks
KN
 
You could use a popup form instead. This could be an advantage because it could be moved around the screen by the user.

The Tag property is a text string. Look in the Properties of any object. This is where you will enter the character you want appended to the textbox.

For a button it would be referred to in VBA by the expression:
Forms!formname!buttonname.Tag

The target form and textbox names will need to be recorded as string variables. I would use the on click event procedure of the target textbox to set these variables and pop up the keyboard form.

These would be set by lines like:

Code:
strTextboxname = Me.ActiveControl.Name
strTextboxname = Me!textboxname.Name

The click event of the keyboard buttons would have something like:

Code:
strCurrentText = Forms(strFormname).Controls(strTextboxname).Text
Forms(strFormname).Controls(strTextboxname).Text = strCurrentText & Me!buttonname.Tag

The keyboard should also have a button to close its form.

Try not to be too intimidated by all this. As you said you are "new with this" you are likely to be at the foot of a steep learning curve especially if you have not used VBA much. Persistence will get you there and the understanding you gain will be invaluable.

Get a form up with one button on it and take a good look at the Properties window of the button.
 
Last edited:
Thank-you for the encouragement…

But… I still can’t get it… I’m not to sure if I am getting the whole concept right…

So is that every text box that I use the button I have to put the first code into the On Click Event… or is it the second one? I am not to sure why I need to use to On Click event for the text it self. I know I use that button, but not to sure why the text itself…

I put the Forms!formname!buttonname.Tag in the Properties Tag part of the button… (I think I did this right)


I just need some more explanation.


I have attached my sample of it too


Thank-you so much for you help...
 

Attachments

Sorry for the delay in replying.
See attached edited database.

The main changes required were:

Declare Global Variables in a standard module. I called it GlobalVariables but they can be declared Public in any Standard (not form) Module. Global variables are available to all modules and are required in this case to pass the form and control names between the two forms.

The Tag property of the button needed to be the actual character to be added to the textbox.

Your actual button name needed to be used in the code rather than the buttonname placeholder I used. I also changed the button name slightly but this isn't important.

I mistakenly used the bang operator (!) with Forms and Controls. It should have been the dot (.) because in this context Forms and Controls are properties rather than Colllections as when referring to Forms!formname etc. Similarly with ActiveControl which is a property of the form. (I have now fixed this in my orignal post.)

You can actually just use dots everywhere if you like because Access substitutes the bang internally as required.

You will also notice I added the Option Explicit declaration to the modules. This means that all variables must be declared. It is good practice because it avoids unrecognised errors caused by spelling mistakes.

Hopefully this will get you to the next level. Post back if you need more help and I will endeavour to reply sooner next time.
 

Attachments

Last edited:
Another thought. Since the character to be added is the same as that displayed on the button you can use the Caption property of the button instead of the Tag property.
 
:D Thank-you so MUCH for the HELP... but I need Help again!!

It works great until I need to add certain letters... On the VBA it show "?" For example [FONT=&quot]ả... I was so happy then that burst my bubble :(.... I try everything.. Chang the button name to some random name but still keep the tag.. and the Caption the same... Didn't work at all... I try did try looking at way I can show the character on VBA... *but it was very confusing :confused::confused:!!**

Your lasted post saying about I don't have to use Tag but use Caption property :confused: I am not to sure how to do that.. I try searching on Google for example.. but I only came up when need change the caption name.. but nothing about keeping it the same...

Is their a easily way that I can just push a button and my character goes Capital ? If not I can just do the long way... do two form, one small letter, one capital letter... :p

Thanks a lot!!!

Kristine




[/FONT] [FONT=&quot][/FONT]
 
[FONT=&quot] ** the example was to small.. I blew it up now :D
ả ạ ă ắ ằ
[/FONT]
 
Is the problem with:
what is displayed on the button (Caption)?
what is entered in the Tag?
what is entered in the textbox after you press the button?

The button name can be anything so long as you change it in the VBA code to match. Probably best avoid using the odd characters in the name. Call them btn1, btn2 etc if you like.

The VBA code itself doesn't ever need to use the character. It simply refers to the Tag and appends it to the textbox.

If the caption works fine the code can refer to the Caption property instead of the Tag.
 
For the capitals we need to store two characters. There are many ways this could be done.

One character could be the Caption (assuming that works fine) and the other as the Tag. Pressing the Shift would swap the code that inserts the character. The selection of the capital would be part of the code based on shift being on or off at the time.

It would even be possible to change the captions from the lower to upper case when the Shift was pressed so the user would see what was to be inserted.

This is an interesting project.
 
Thanks for help :p

Ya I come up with very hard project.. :) but I like to challenge myself... I just start access a month ago and I almost complete my database for my temple just need to add this key board system...

I like your idea... though is it possible that it'll automatically know I want to switch to the other code if I just push a button... I got my idea from this website http://vdict.com/ and click onto the Vietnamese keyboard.. where you click on the shift option it turn all the word into capital..

How would I go about doing this Shift On and Off...

Thanks again :)
 
Yes that keyboard is the kind of functionality I was describing.

Assuming the Caption is the lower case character by default and the uppercase is stored in the Tag, pressing the Shift would run a loop through all the buttons on the keyboard and swap the tag for the caption.

Name your character keys using a consistent pattern, say key1, key2 etc
This part of the code goes somethng like this:

Code:
Dim btn as Control
Dim temp as String
 
For Each btn In Me
   If Left(btn.Name,3) = "key" Then
      temp = btn.Caption 
      btn.Caption = btn.Tag
      btn.Tag = temp
   End If
Next

The shift key will swap the Caption and Tag.
There is no need to indicate the state of the ShiftButton since it is indicated by what is shown on the keys.

Note that you would use the Caption as the character to insert into the textbox.

BTW Rather then writing the code on every button you should really write it as a sub which is called by the button.

This way the button_click code is simply:

Code:
Private Sub key1_Click()
   InsertCharacter
End Sub
While the processing is done in a single Sub.

Code:
Sub InsertCharacter()
 
   ButtonName = Screen.ActiveControl.Name
 
Do the stuff here with the ButtonName variable identifying the button like this: 
Me.Controls(ButtonName)
 
End Sub
This way the sub can be enhanced without having to rewrite it on every key.
 
Galaxiom,

I am not to sure where to put the first code and the last code... The first code do I put the code on the onclick of every btn ?? or do I put in the form onclick?? I try putting it it in every possible way.. so not to sure...

Thanks Kristine

HiTechCoach: thanks for example!
 
The first sub (key1_Click) is for a button called key1.
Each button has the same line which calls the InsertCharacter Sub.

Just change the name of the button to match the real button names on your form.

The InsertCharacter Sub is just another sub in the keyboard form. It is only called by the button procedures. This is the part that does the actual character insertion.


Code:
Sub InsertCharacter()
 
Dim Buttonname as String
Dim strCurrentText As String
 
   ButtonName = Screen.ActiveControl.Name
 
   strCurrentText = Forms(strFormname).Controls(strTextboxname).Text
 
   Forms(strFormname).Controls(strTextboxname).Text = strCurrentText & Me.Controls(ButtonName).Tag
 
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom