Access Vba Interview Questions

2) Mention where you can write your VBA program for Macro?

Module is the place where you can write VBA program for Macro, to insert a Module navigate to Insert ->Module

2) Explain what is the size limitation for an Access database?

The Access 2.0 database has the size limitation of 1 gigabyte.

1 How to Declare a Variable in VBA?

To use a variable, you need to declare it first by using the “Dim” keyword. In the following code example, you can see that we have used the “Dim”, the name of the variable, and then the data type.

In the above example, we have used a dim statement to declare the “startDate” variable and specified the date as the data type. And after that, we have specified a date value for the variable. You second learn more about variables from here.

2 How to test conditions in VBA?

In VBA, to test conditions there are two major methods you can use the IF statement and select-case. Both methods are a little different from each other. With the IF statement you can test one condition at a time (until you use a nested IF) and with the select case, you can test multiple conditions.

15) What is the code to find a last used Row in a column or last used Column of a row?

To find the last row in a column, the command used is End(xlUp) and to find last column in a row, the command used is End(xlToLeft).

10) Explain how you can create a table using MAOL (Microsoft Access Object Library)?

To create a table using MAOL, you have to pronounce a variable of type object and then initialize it with the CreateTableDef() method of the recent database object. This technique takes argument as the name of the table.

How to use the Visual Basic Editor?

Once you activate the developer tab, you can access the visual basic editor from there.

When you click the “Visual Basic” button you will get a visual basic window that opens separately.

Here’s a complete guide that can help you to understand to use the visual basic editor to write VBA codes.

2 How to Refer to a Worksheet in a VBA Code?

To refer to a worksheet you need to use the worksheet object and then you need to specify the name of the worksheet that you want to refer to. In the following example, we have used the worksheet object and then specify the “Sheet1”.

As you can see we have used “Sheets” and “Worksheets” to refer to the same worksheet, hey you need to understand the difference between sheets and worksheets, and here’s the complete guide for this.

9) Explain how you can export data in Excel format?

  • From the toolbar click on the External Data tab
  • Click Excel on the Export group
  • It will open the export excel spreadsheet dialog box
  • Specify the destination of the file name and format
  • When you click OK, it will export the data to Excel spreadsheet
  • 1 What are the VBA Data Types?

    While declaring a variable (or even a constant) you need to specify the data type. Declaring the data type helps VBA to understand which type of value you want to store in the variable. Let us say if you want to store a date in the variable as we have done in the previous example, you need to specify the data type as the date.

    Option Explicit is a statement that you can use at the start of a module, and once you use this statement, we can notify you if you skip declaring a variable.

    The above screenshot is the best example where we have used the variable “a” without actually declaring it, and while executing the code, there is a compile error message that “variable not defined”. As you can see at the top we have used the option explicit statement.

    Like a variable, a constant also stores a value. But, in the case of a constant, you can change the value you have stored in it. To declare a constant you need to use it the same way that you use it in a variable but instead of “Dim” you need to use the work constant to declare (see the following example and here’s the link to learn more).

    Learn Excel – Video 188 – VBA Interview Questions – Part1

    Related Posts

    Leave a Reply

    Your email address will not be published. Required fields are marked *