Avatar of Roman F
Roman F
Flag for United States of America asked on

help me with Data Grid in access vba

Hi, experts.
I would like to ask you where to start with data grid control.
I have a simple form with a combo box with dates (populated from the main query) and I want to put data grid control or something else on same form to get the results of the query based on selected criteria from the combo box. The problem is I cannot find the data grid control or may be I can use something different instead of.  Please help
Microsoft AccessSQL

Avatar of undefined
Last Comment
Jeffrey Coachman

8/22/2022 - Mon
SOLUTION
Anthony Berenguel

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Roman F

ASKER
thank you for the fast respond, any other idea?
ASKER CERTIFIED SOLUTION
Jeffrey Coachman

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jeffrey Coachman

like so:
screenDatabase43.mdb
Roman F

ASKER
thank you very much
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Jeffrey Coachman

;-)
Roman F

ASKER
I am sorry, where is the place where combo box connecting to list box???
Jeffrey Coachman

But I have to also thank you for phrasing your question correctly:

<I want to put data grid control or something else on same form ...>

Many times a person hears about the Datagrid (or is used to using one in VB6), so they will only want a Datagrid solution.

By stating: "or something else", you made it clear that you just needed something to display the results.

This enabled aebea and I to get you a alternate solution quickly.

Enjoy the weekend...
;-)

JeffCoachman
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Roman F

ASKER
yes, you are right
Roman F

ASKER
never mind, :))
thank you
Jeffrey Coachman

<I am sorry, where is the place where combo box connecting to list box??? >

The combobox is not "connected" to the listbox.

What happens is that the Listbox "Looks" at the combobox for the criteria (filter)

You can see this by examining the RowSource Property of the listbox:

SELECT YourTable.rID, YourTable.rDate, YourTable.rCustID, YourTable.rAmount
FROM YourTable
WHERE (((YourTable.rDate)=[Forms]![YourForm]![Combo0]));


...Here the WHERE clause is the filter.
You can see that it points to the combobox.

So you can translate the SQL to say:
    Display (SELECT)  all fields
    From YourTable
    But only show records WHERE the rDate value is the same as the date in the combobox.

;-)

JeffCoachman
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Roman F

ASKER
and also, and that part i missed:
Private Sub Combo0_AfterUpdate()
Me.List2.Requery
End Sub
Jeffrey Coachman

yes, ...
You need to requery the listbox each time you select a new value in the combobox.
As you can see, this is done on the After Update event of the combobox.