MS Access VBA Interview Questions and Answers with Examples

Home/100+ VBA Interview Questions and Answers with Examples/MS Access VBA Interview Questions and Answers with Examples

MS Access VBA Interview Questions and Answers with Examples

MS Access VBA Interview Questions and Answers explained with Example macros. Here are the list of most frequently asked basic MS Access VBA interview questions. All the questions are answered with simple examples. These questions will help you to answer basic questions to deal with MS Access VBA Programming/Development.

PREMIUM TEMPLATES LIMITED TIME OFFER

ON SALE80% OFF

50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates


Here is the following VBA procedure to create table in the required database using VBA.

'Create table in the required database using VBA
Sub sbCreate_Table()
Dim DBase As Database
'
'Open Databse
Set DBase = OpenDatabase("C:\Users\PNRao\Documents\MyDatabase.accdb")
' Create a table with three fields.
DBase.Execute "CREATE TABLE MyTable " _
& "(EName CHAR, ENumber INT, Elocation CHAR);"
DBase.Close
End Sub
Here is the following VBA procedure to delete table from a specific database using VBA.

'Delete table from a specific database using VBA
Sub sbDelete_Table()
Dim DBase As Database
'
'Open Databse
Set DBase = OpenDatabase("C:\Users\PNRao\Documents\MyDatabase.accdb")
' Create a table with three fields.
DBase.Execute "DROP TABLE MyTable;"
DBase.Close
End Sub
Here is the following VBA procedure to the access database table using VBA.

'Add or Insert records to the access database table using VBA
Sub sbAdd_Records_Table()
Dim DBase As Database
Dim strSQL As String
'
'Open Databse
Set DBase = OpenDatabase("C:\Users\PNRao\Documents\MyDatabase.accdb")
strSQL = "INSERT INTO MyTable values('John2',12345,'U.S');"
' Adding records the table
DoCmd.RunSQL strSQL
DBase.Close
End Sub
Here is the following VBA procedure to update records in the access database table using VBA.

'Update records in the access database table using VBA
Sub sbUpdate_Records_Table()
Dim DBase As Database
Dim strSQL As String
'
'Open Databse
Set DBase = OpenDatabase("C:\Users\PNRao\Documents\MyDatabase.accdb")
strSQL = "Update MyTable set Elocation='U.K' where ENumber=12345;"
' Updating records the table
DoCmd.RunSQL strSQL
DBase.Close
End Sub
Here is the following VBA procedure to delete records in the access database table using VBA.

'Delete records in the access database table using VBA
Sub sbDelete_Records_Table()
Dim DBase As Database
Dim strSQL As String
'
'Open Databse
Set DBase = OpenDatabase("C:\Users\PNRao\Documents\MyDatabase.accdb")
strSQL = "Delete from MyTable where ENumber=12345;"
' Deleting records the table
DoCmd.RunSQL strSQL
DBase.Close
End Sub
Here is the following VBA procedure to alter (Add Column) table in the access database using VBA.

'Alter table in the access database using VBA
Sub sbAlter_Records_Table_AddColumn()
Dim DBase As Database
Dim strSQL As String
'
'Open Databse
Set DBase = OpenDatabase("C:\Users\PNRao\Documents\MyDatabase.accdb")
strSQL = "ALTER table MyTable ADD COLUMN ESal Money;"
' Alter table
DoCmd.RunSQL strSQL
DBase.Close
End Sub
Here is the following VBA procedure to alter (Delete Column) table in the access database using VBA.

'Alter table in the access database using VBA
Sub sbAlter_Records_Table_DeleteColumn()
Dim DBase As Database
Dim strSQL As String
'
'Open Databse
Set DBase = OpenDatabase("C:\Users\PNRao\Documents\MyDatabase.accdb")
strSQL = "ALTER table MyTable DROP COLUMN ESal;"
' Alter table
DoCmd.RunSQL strSQL
DBase.Close
End Sub
Here is the following VBA procedure to alter (Delete Column) table in the access database using VBA.

'Alter table in the access database using VBA
Sub sbAlter()
Dim DBase As Database
Dim strSQL As String
'
'Open Databse
Set DBase = OpenDatabase("C:\Users\PNRao\Documents\MyDatabase.accdb")
strSQL = "ALTER table MyTable DROP COLUMN ESal;"
' Alter table
DoCmd.RunSQL strSQL
DBase.Close
End Sub
Here is the following VBA procedure to export access table to Excel using VBA.

'Export access table to Excel using VBA?
Sub sbExport_Table_Excel()
'Variable declaration
Dim strTable As String
Dim strWorkbook As String
'Change target file path
strWorkbook = "D:/MyTable.xlsx"
'Source table name
strTable = "MyTable"
'Export table to Excel
DoCmd.TransferSpreadsheet transfertype:=acExport, spreadsheettype:=acSpreadsheetTypeExcel12, _
tablename:=strTable, FileName:=strWorkbook, hasfieldnames:=True
End Sub
Here is the following VBA procedure to change existing table name in access using VBA.

'Change existing table name in access using VBA
Sub sbChange_Table_Name()
'Variable declaration
Dim strOTable As String
Dim strNTable As String
'Old Table name
strOTable = "MyTable"
'New Table Name
strNTable = "EmpTable"
'Export table to Excel
DoCmd.Rename strNTable, acTable, strOTable
End Sub
Here is the following VBA procedure to find specified data in an access table using VBA.

'Find specified data in an access table using VBA
Sub sbFindData_InTable()
'Variable declaration
Dim strData As String
'Specify Data to search
strData = "John"
'find specified data
DoCmd.FindRecord strData,, True,, True
End Sub
Here is the following VBA procedure to open an existing access table in Print View using VBA.

'Open an existing access table in Print View using VBA.
Sub sbPrintView_Table()
'Variable declaration
Dim strTable As String
'Specify table Name
strTable = "EmpTable"
'find specified data
DoCmd.OpenTable strTable, acViewPreview
End Sub
Here is the following VBA procedure to open an existing access table in design View using VBA.

'Open an existing access table in design View using VBA.
Sub sbDesignView_Table()
'Variable declaration
Dim strTable As String
'Specify table Name
strTable = "EmpTable"
'find specified data
DoCmd.OpenTable strTable, acViewDesign
End Sub
Here is the following VBA procedure to open an existing access table in normal View using VBA.

'Open an existing access table in normal View using VBA.
Sub sbNormalView_Table()
'Variable declaration
Dim strTable As String
'Specify table Name
strTable = "EmpTable"
'find specified data
DoCmd.OpenTable strTable, acViewNormal
End Sub

Here is the link for more VBA Interview Questions and Answers. These are explained for examples.
100+ VBA Interview Questions

LIMITED TIME OFFER

Related pages


vba unprotect sheettutorial vlookup excel 2007how to insert a textbox in excelproject timeline template excel 2007multiselect listbox vbaexcel macro vlookupexcel macro open foldermessage box vbscriptvlookup excel templatedml languageexample of lookup function in excelexcel tasks templatedelete duplicate entries in excelinterior color excelexcel chrsumif functionworkbooks.saveexcel vba columnwidthweekly task report template excelexcel multiple criteriavlookup simple examplevba tooliserror functionvba typeofinsert a column in excelappend excel filesvba excel format cellunprotecting an excel worksheetwriting an if statement in excelvba examples for excelexplain macros in excelvba copy sheet to new workbookhow to open excel workbookhow to protect a workbook in excelhow to add developer tab in excelexcel vb macrohow to unlock protected excel sheet without passwordintroduction to vbavba pivot table rangemacro workbookvba delete fileexcel option button valuevlookup with and functionhow to use the match function in excelunlock an excel filesimple v lookuptick on excel spreadsheetvba access excelrange.autofilterrows excel vbahow to see developer tab in excel 2010excel vba nested ifdml definitionexcel joining cellsvba application.enableeventsproject costing spreadsheetexcel macros for dummiesreverse vlookupmerge multiple excel files into one sheet vbaadvanced filter in excel 2013listbox codehow to collapse rows in excelexcel 2003 calendar templatevba tablevisual basic macros excelexcel password cracker macroestimation template excelexcel chart tutorialprotect worksheet vbapivottables in excelvba for excel tutorialvba excel selectvb msgbox syntaxconcatenation in vbasas find duplicateseasy way to find duplicates in excel