Wednesday, November 6, 2013

MS OFFICE ACCESS 2010 Creating Blank Database Form and VBA code module


-----

1) Create New MS Office Access Database
2) Creating New Form
3) Adding Control Objects into the form
4) Using Object Properties Panel
5) Adding VBA codes


1) Create New MS Office Access Database

1.1) Go to File/New
1.2) In the available templates, select Blank database.
1.3) In the File Name text box (on the right side of application window), type the name MyDbVba1.accdb
Click Create.
1.4) New Database is created.

2) Creating New Form

2.1) Click Create Tab.
Click Blank Form button.
2.2) A new form is created.

3) Adding Control Objects into the form

3.1) There are a number of control objects on the form.
3.2) Click Textbox object and then click on a blank area on the form.
Repeat for a second time.
Don’t worry about the name.
3.3) Add a button control.
Click the button icon.
Click on an area below the text box.
When a Command Button dialog box appears, click Cancel.
Don’t worry about the name/label of the button.

4) Using Object Properties Panel

4.1) Find the Property Sheet button and click it.
4.2) Property Sheet will be displayed at the right side of the application window.
4.3) Change the name of the objects as follows:
lblInput1
txtInput1
lblInput2
txtInput2
cmdButton1
        
You can change the caption of the objects by going to the Format Tab and edit the Caption field.

5) Adding VBA codes

5.1) In the Property Sheet, find the Event Tab.
Make sure the button labeled as Process is selected.
Under the Event tab, find the On Click event, click “…” button.
5.2) When the Choose Builder dialog window pops up, choose Code Builder.
5.3) You may get error message.
5.4) Switch to Design View.
5.5) In the Property Sheet, select Form and set Has Module Property to Yes.
5.6) Repeat Step 5.1 and 5.2.
VBA Editor window appears.
5.7) Type :
    MsgBox "Hello", , "Test"
5.8) Test Run.
Find the Run button and click it.
5.9) Go back to Access.
5.10) Click View/Form View
5.11) If you click the button labeled as “Process”, you should get the Message Box dialog window as follows:





DOWNLOAD: 


No comments:

Post a Comment