Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox that changes control source 2

Status
Not open for further replies.

SeadnaS

Programmer
May 30, 2011
214
Hi,

I have a combobox that lists all the tables on my database I want to be able to select a table from the combo box and have the combo box change the forms record source to that table. I have set the control source of the combo to =[RecordSource] and the row source to

SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") And (Left$([Name],4)<>"Msys") And (MSysObjects.Type)=1 ORDER BY MSysObjects.Name;

to list the tables. I get a list of the tables ok and it shows the table the form is currently using when it opens, but it will not let me change the control source to another table it gives me this msg on the status bar: "Control can't be edited; It's bound to the expression '[RecordSource]'".

Thanks for any help received.
 
How are ya SeadnaS . . .

For the combo clear the [blue]control source[/blue] and copy/paste the following to the [blue]After Update[/blue] event:
Code:
[blue]   Me.RecordSource = Me.ComboboxName[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
As i'm sure you're aware im no programmer! Anyway, i have another problem that has shown up since. I have another combobox for displaying records on my form. It will only select records from the first table so how do i get it to show records from the table selected in my recordsource combo box?

This is the combobox row source:

SELECT Table1.ID, Table1.LOT_NO FROM Table1;

The control source is empty.
 
Me.RecordSource = Me!ComboboxName
Me![another combo].RowSource = "SELECT ID,LOT_NO FROM " & Me!ComboboxName

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
hey just trying to implement those 2 lines of code. where should i be placing them?
 
that code is not working for me i placed each line in the after update events of my combo boxes. The combo box isn't showing any records.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top