Introduction to VB Access:
Using my Donor database, I created a new form with out linking it to a table (in other words I didn't make the table or query selection when the new form selection box came up).
I got a blank design screen on which I can work. Note when you bring up the Toolbox there is an icon that looks like a magic want with stars, this is a toggle switch that can be used to activate and deactivate the wizards. I deactivated it.
Now, using the Toolbox, I put a text field and command button on the form screen. I named the text field txtShowName and the label that goes with it lblShowName with a caption of Show Name:. I changed the font size to 12 and the font weight to bold. I named the command button cmdClick. By using the type of field more the name I provide clarity. Note this is a common technique in VB. These name properties will be the way you refer to the data in VB.
Now we will look at the properties for the command button (cmdClick) and select the click event to create code. Note when you press the … next to the OnClick Event you will see the options to build the code. The choices are: Expression Builder, Macro Builder, Code Builder. We are going to use the Code Builder for this exercise.
When I get to the Code Builder, I can add the code that will display Computer Information Systems in txtShowName.
First, I set the focus to the box where I want to put the information. Remember the box is called txtShowName so I append the .SetFocus to set the focus to that field. Then I assign the words "Computer Information Systems" to the Text property of the txtShowName field. The other information is added automatically. That includes the Option clauses, the Private Sub cmdClick_Click() and the End Sub. I added the two lines of code that deal with the processing that I want to do with txtShowName.
txtShowName.Text = "Computer Information Systems"
OnClick now shows as having an Event Procedure.