VBA tutorial-Access 2007: Visual Basic for Applications


What is VBA ?

VBA stands for Visual Basic For Applications. VBA was created by Microsoft and is used in many Microsoft products such as Ms. Word, Ms. Excel, Ms. Access, Ms. Outlook, etc. VBA was created in the purpose of helping Microsoft users in extending their ability by writing code to manage data in more efficient and effective way.

Where can you write the VBA code? Simply you can write your VBA code by using Visual Basic Editor. To open Visual Basic Editor, after opening a database, you can press Alt with F11. For a database file (never has had VBA code before) it looks like this:

VBA Editor




Comments

CAPTCHA image
Dara comment

 Dara

Option Explicit
Dim Cn as New ADODB.Connection
Private Sub_Form_Load()
Cn.Open "Provider=SQLOLEDB; Data Source=ServerName; Initial Catalog=DatabaseName;UserID=UserName; Password=Passw"
End Sub
You will need to replace ServerName with the name of your server (installed SQL Server), DatabaseName withe the name of your data file that you want to connect to, UserName with the name of the user to login to SQL Server, and Passw with the password used to login to SQL Server.


2013-03-13 10:10:00
sophea comment

 sophea

Hello! sirs I want to know code VBA in MS.access connect to MS.SQL Server for Back end.


2013-03-13 06:29:00



This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.