changing content of listbox

J

Jean-Paul

I have a form wit a listbox: Naam_gemeente

The default recordsource is:
SELECT [Adressen metaal].Gemeente, [Adressen metaal].land FROM [Adressen
metaal] GROUP BY [Adressen metaal].Gemeente, [Adressen metaal].land
HAVING ((([Adressen metaal].land)=[forms]![hoofdmenu]![tekst40])) ORDER
BY [Adressen metaal].Gemeente;

This is perfect

Now I created a pushbutton to change the recordsource upon klicking:

Private Sub Bedrijfknop_Click()
Me!Naam_gemeente.RecordSource = "SELECT [Adressen metaal].Naam,
[Adressen metaal].land FROM [Adressen metaal]GROUP BY [Adressen
metaal].Naam, [Adressen metaal].land HAVING ((([Adressen metaal].land) =
[Forms]![hoofdmenu]![Tekst40]))ORDER BY [Adressen metaal].Naam;"
Forms!bedrijven.Refresh
End Sub

This returns an errormessage saying
the method object doesn't support this object

What am I doing wrong?

Thanks
 
B

Brendan Reynolds

Jean-Paul said:
I have a form wit a listbox: Naam_gemeente

The default recordsource is:
SELECT [Adressen metaal].Gemeente, [Adressen metaal].land FROM [Adressen
metaal] GROUP BY [Adressen metaal].Gemeente, [Adressen metaal].land HAVING
((([Adressen metaal].land)=[forms]![hoofdmenu]![tekst40])) ORDER BY
[Adressen metaal].Gemeente;

This is perfect

Now I created a pushbutton to change the recordsource upon klicking:

Private Sub Bedrijfknop_Click()
Me!Naam_gemeente.RecordSource = "SELECT [Adressen metaal].Naam,
[Adressen metaal].land FROM [Adressen metaal]GROUP BY [Adressen
metaal].Naam, [Adressen metaal].land HAVING ((([Adressen metaal].land) =
[Forms]![hoofdmenu]![Tekst40]))ORDER BY [Adressen metaal].Naam;"
Forms!bedrijven.Refresh
End Sub

This returns an errormessage saying
the method object doesn't support this object

What am I doing wrong?

Thanks


A listbox doesn't have a RecordSource property. Try using the RowSource
property instead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top