Joomla gallery by

Discover GYL Solutions

Home BlogAccess TipsDrag and drop between two Access forms

IT consulting, trainings

Drag and drop between two Access forms

I explain today one of my best kept secrets: how to make a drag & drop between two Access forms!

This will give an added value to your applications improving significantly the user experience!

This tutorial explains the basics of the trick to make a nice drag and drop in Access. After, you can adapt and improve this code to add it to your applications.

Level: Intermediate / Advanced

Compatibility: Tested with Access 2003 and Access 2007

This tutorial require to already have some basic knowledge in creating Access forms and VBA code manipulation.


We will create a form with two lists of products: one with a list of all products, and another to put the list of selected products. Selecting a product will be done via a drag and drop from one list to another.

As you probably already know, Access does not support drag / drop (hence the importance of this tutorial Complice). For this, we will use the events mouse up / down and the mouse position.

Preparation of the database structure

Products table

We are going to create a very simple "tbProducts" table to store all our products.


idProduct Auto Number (Key)
ProductReference String (50)
ProductDescription String (255)
ProductIsSelected Yes / No


Fill then this table with a few records.


Sub form of non selected products

Create a new form with the following properties:

  • Default View: Continuous Forms
  • Record Selectors: No
  • Navigation Buttons: No
  • Dividing Lines: No
  • Record Source: SELECT * FROM tbProducts WHERE ProductIsSelected=0;
  • Allow Additions: No
  • Scroll Bars: Vertical Only

Save the form with the name "sfrmProductsNotSelected".

Add a form header, the fields ProductReference, ProductDecription, idProduct, ProductIsSelected and a button.


Specify the following parameters:

  • Name of the form header: FormHeader
  • Name of the detail section of the form: FormDetail
  • Name for the fields ProductReference and ProductDescription, Enabled = No and Locked = Yes
  • For the fields idProduct and ProductIsSelected, Visible = No
Save and close this form.

Sub form for the selected products

As we are lazy, we will just make a copy / paste of the previous from and name it "sfrmProductsSelected".

You then just have to change the Record Source property to : SELECT * FROM tbProducts WHERE ProductIsSelected=-1;

Creation of the main form

We will now create the main form containing the two lists of products. The structure will be as follows (sorry for the french!):


Create a new form named "frmProducts" with the following parameters:

  • Default View: Single Form
  • Record Selectors: Yes
  • Navigation Buttons: No
  • Dividing Lines: No
  • Scroll Bars: None
  • Name of the detail section: FormDetail

Then, in design mode, drag / drop in two forms created above.

With a little effort of formatting, you should get something like this:


That's it, we have the basis, we can now go to the more serious part!

Add comment

Security code

Why should you choose GYL Solutions?

If you have only 5 minutes, discover the 10 key points that will make GYL Solutions one of you preferred partners!

The 10 key points

You have a project?

Contact us to discuss it in and get a detailed proposal!

Contact form

Go to top