Access - Display query in form

Associate
Joined
30 Oct 2002
Posts
309
Hi,

I am putting together a Access database, which I would like to display the contents of a query within a form.

Each entry will have a button to the right, with say edit or view more details, which will then display the relevant data in another form.

Is this possible?

Many Thanks
 
Associate
Joined
14 Mar 2007
Posts
1,667
Location
Winchester
Yes all very possible.

Lots of ways to do it but if this is going to be single user database then you can set the .recordsource propery of the form to your query. Each time the form opens it will display the results of that query.

If it is going to be a multi user DB with concurrent access and a shared backend then you are really going to be looking at holding the results of the query in an array and then populating a listbox object or similar from the array. You can set the .recordsource property to a function I believe but this gets quite complicated.

All depends on what your db is going to do and how many people are going to use it.
 
Associate
OP
Joined
30 Oct 2002
Posts
309
Many Thanks. Yes, it is a single user database.

Do you have an example or website I can look at to show me how this is done?

Also, how do I put the edit buttons next to each entry to display more details in another form?

Many Thanks
 
Associate
Joined
14 Mar 2007
Posts
1,667
Location
Winchester
accessprogrammers.co.uk is a decent place but there are lots of different forums. Most of them expect you to put in most of the hard work though, so best to go at least with some examples of what you have done.

You can actually do most of this this without code if you are not comfortable doing this.

I'm assuming you are on Access 2007+. All you need to do to bind a query to a form is use the form wizard. This assumes one query per form by the way.

So go to the create tab on the ribbon and you will see "Form Wizard". Press this which will then open up a guide, basically select the specific query you want from the drop down, and the specific fields you need from the list boxes. This will automatically generate the form for you, name it something useful.

To open it from another form you need to create a button event. I would recommend doing this in code but again you don't have to. If you drag a command button to your main form, another wizard will open, select Form Operations from the list box and then open form and then point it to the form you previously created in the wizard.

This creates an event for you, so every time you click that button the form will open, which will populate itself based on the query you bound the form too.

Note: Just thought if you want to view this as a "table view" make sure that you set allow form view on the properties of the form where you bound the query to no, datasheet view should already be set to yes.
 
Last edited:
Back
Top Bottom