Link to home
Start Free TrialLog in
Avatar of Roman F
Roman FFlag 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
SOLUTION
Avatar of Anthony Berenguel
Anthony Berenguel
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Roman F

ASKER

thank you for the fast respond, any other idea?
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Roman F

ASKER

thank you very much
Avatar of Roman F

ASKER

I am sorry, where is the place where combo box connecting to list box???
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
Avatar of Roman F

ASKER

yes, you are right
Avatar of Roman F

ASKER

never mind, :))
thank you
<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
Avatar of Roman F

ASKER

and also, and that part i missed:
Private Sub Combo0_AfterUpdate()
Me.List2.Requery
End Sub
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.