If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Changing Control Source on a Form

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-15-10, 10:28
uoflstaples uoflstaples is offline
Registered User
 
Join Date: Nov 2010
Posts: 6
Changing Control Source on a Form

I have created a form that captures data regarding a certain program. I need to create that exact form for other programs as well that save to different tables.

I copied my initial form and renamed it to reflect another program. Now I'm trying to change the control source to point to a different program table than my initial one.

What is the easiest way in Access 2010 to change the control source for all of these fields without having to rebuild the form every time?
Reply With Quote
  #2 (permalink)  
Old 11-15-10, 16:52
Sinndho Sinndho is online now
Registered User
 
Join Date: Mar 2009
Posts: 3,446
If you only need to change the RecordSource of the form, it's easy:
Code:
Me.RecordSource = ...
For changing the control source you need to have a list somewhere (in a table, an array, ...) containing the names of the column of the data source. You can then use (here for text boxes):
Code:
Function ChangeControlSource()

    Dim ctl As Control
    
    For Each ctl In Me.Controls
        If ctl.ControlType = acTextBox Then ctl.ControlSource = "<Something>"
    Next
            
End Function
__________________
Have a nice day!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On