How to change the Row source in a table to a query?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    How to change the Row source in a table to a query?

    I have had to change the names of some fields in a table and this resulted in comboboxes not working anymore.
    My plan is to create a query based on the new field names/table name, and then replace the current Row source with that.(the field and table names have been changed using VBA already)
    This is some code for an existing combobox on a form to change it to a query.
    Code:
    Forms!Employees!cmboNames.RowSourceType = "Table/Query" 
    Forms!Employees!cmboNames.RowSource = "EmployeeList"
    How do i adapt it please?
    I want to change the sql in the original table to a query name but leave the rest of the properties and sizes the same. Is it possible?

    [imgnothumb]http://bytes.com/attachments/attachment/7075d1373474916/rowsource-change.jpg[/imgnothumb]
    Attached Files
    Last edited by zmbd; Jul 10 '13, 07:16 PM. Reason: [z{inserted image inline}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    This is hard to follow and you've started mixing terms:
    want to change the sql in the original table to a query name but leave the rest of the properties and sizes the same. Is it possible?
    What are you doing?


    You can, at runtime, alter the controls recordsource property such as:
    Code:
    strSQL = "some valid SQL here, or a query or table name"
    me.cboCtrl.recordsource = strSQL
    Using the same concepts, one can go thru the forms collection, then step thru each form's control collection, searching for the temrs to change. There was something written here on Bytes about doing something along those lines; however, I can't find the link today.

    Comment

    Working...