Dabbas
Dabbas

Reputation: 3230

How to add grid in Access form?

How can I add grid in access form? I need to build a form contains of two grids and buttons to add,edit, delete the data in them. Can I do this with out using a lot of VB code ?

Upvotes: 2

Views: 12146

Answers (1)

Albert D. Kallal
Albert D. Kallal

Reputation: 49009

You can likely achieve this without any code. You can create one large form, and then into that form drop in a datasheet or a continues form. (so you can drop two forms into the one larger form). In access these are called sub forms.

Thus a grid like this can be created without any code and such grids allow editing of data:

The follow thus have two sub forms placed in one larger form:

enter image description here

In above the left side is a listbox, but it could have well been a sub form (a data sheet, or a continues form). The right side is in fact a sub from (a continues form) since I wanted to have one column based on a check box.

To filter the two sub forms based on customerID, then bind the main form to a table with customerid.

Then when you drop in the two sub forms, you set the link master/child settings. In fact the wizrard will do this. So perhaps you re-create the main form bound to a table with customerID. Then in design mode simply drag + drop in the two sub forms you created. The wizard should setup the link master/child settings for you.

Now, use this one line of code to open this main form:

Docmd.OpenForm "my main form",,,"customerid = " & lngCustID

This will result in the main form loading only the one record, and the two subform will ALSO be automatic filtered to only reocrds matching the customerID.

Upvotes: 3

Related Questions