Results 1 to 3 of 3
  1. #1
    JeffChr is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    82

    Anyone know how to change change the control source for all the text boxes on a form in VBA ?


    Anyone know how to change change the control source for all the text boxes on a form in VBA ?

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Can you explain this? The forms record source should be either a table or a query. Is the form not bound?

  3. #3
    JeffChr is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    82
    I found this, which works:

    In the form:

    Private Sub Form_Activate()


    Dim ctl As Control

    For Each ctl In Me.Controls
    If HasProperty(ctl, "ControlSource") Then
    If Len(ctl.ControlSource) > 0 And Not ctl.ControlSource Like "=*" Then
    Debug.Print ctl.ControlSource
    End If
    End If
    Next

    End Sub

    general module:

    Public Function HasProperty(obj As Object, strPropName As String) As Boolean


    'Purpose: Return true if the object has the property.

    Dim varDummy As Variant

    On Error Resume Next
    varDummy = obj.Properties(strPropName)
    HasProperty = (Err.Number = 0)

    End Function

    credit: www.allenbrowne.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 0
    Last Post: 07-04-2014, 12:20 AM
  2. Change a Control Source of a textbox VBA
    By WickidWe in forum Forms
    Replies: 1
    Last Post: 01-05-2014, 03:01 PM
  3. Replies: 3
    Last Post: 10-07-2013, 12:27 PM
  4. Replies: 3
    Last Post: 01-03-2013, 04:32 PM
  5. Copying entry form, change control source
    By Bdowns in forum Access
    Replies: 11
    Last Post: 02-06-2012, 05:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums