form combo control source
RH

Forum home » Delegate support and help forum » Microsoft Access Training and help » Access: Form Combo control source (change) | Access forum

Access: Form Combo control source (change) | Access forum

resolvedResolved · Medium Priority · Version 2010

Edited on Thu 26 Jun 2014, 17:19

Joe has attended:
Access Intermediate course

Access: Form Combo control source (change)

Dear Best STL,

I have a Combo control on a form.
In its properties > row source, I've created an SQL statement using the query builder. The Combo values come from a table field 'colours1' from the table 'TBL_Colours', so the query design grid has:
Table: 'TBL_Colours'
Field: Colours1.
All works fine, but, using another combo or option buttons on the same form, I would like somehow to be able to change the table field source to 'colours2' or 'colours3', which will contain a different set of colours.
How can this be achieved?
I've tried many things including giving the query field (in the design grid) an alias and tried to concatenate words together to make up 'colours2' or 'colours3' or tried to refer to other fields etc, but nothing works.

You help is appreciated!
Best regards.
Joe

RE: Access: Form Combo control source (change)

Hi Joe,

Thank you for the forum question.


I have a solution for you. I created a table exactly like your table, and a query exactly as your query. In the form I added a combobox and 3 command buttons. I added a on_click event for each of the command buttons and used the code builder. In the code builder I added the code:

Private Sub Command11_Click()
Me.Combo0.RowSource = "SELECT Colours.Colours1 FROM Colours;"
Me.Requery
End Sub

Private Sub Command12_Click()
Me.Combo0.RowSource = "SELECT Colours.Colours2 FROM Colours;"
Me.Requery
End Sub

Private Sub Command13_Click()
Me.Combo0.RowSource = "SELECT Colours.Colours3 FROM Colours;"
Me.Requery
End Sub

If you copy and paste the code you will need to change the names for the command buttons and your combobox to the names for you controls.

This did the job.

I have attached my database with my solution.

I hope this will do the job for you.

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Read more: https://www.stl-training.co.uk/post-34995-form-combo-control-source.html #ixzz36OCfWRAx

Attached files...

35006_colours.accdb

RE: Access: Form Combo control source (change)

Hello Joe,

We have now uploaded the file for this answer.

Regards,

Richard

RE: Access: Form Combo control source (change)

Dear Jens,

Excellent, Thank you very much!

Your explanation was clear so it was easy adapting your code to my needs.
Because the strings in quotes are just SQL statements, I was also able to play around with them, integrating conditions, sorts and filters. This helps a lot.

Many thanks again …until the next one!
Joe


 

Access tip:

Pop up property

If you want to focus the attention of a form / switchboard to a user then you can change the propeties of a form/switchboard for Pop up to On.

This meand tht the focus for the user must be on the form / switchboard

View all Access hints and tips


Server loaded in 0.05 secs.