Results 1 to 5 of 5
  1. #1
    ahseenam is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    6

    Update references in text boxes

    I have a report with a bunch of text boxes where the control source is something like:




    =[Reports]![My Report Name]![Student Total]


    =[Reports]![My Report Name]![Students Classroom Number]


    =[Reports]![My Report Name]![Students Section Count]


    =[Reports]![My Report Name]![Teachers Count]


    ... and so on.




    I have to change [My Report Name] to [My New Report Name]. Field names stay the same. Obviously I don't want to have to go through the form and edit 20 or so text boxes one by one. Does Access have an automated way to do this update? Or how can I use VBA to update my report?

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    You could use OpenArgs for the Criteria. However, unsure why your Report is not bound?

    HTH

  3. #3
    ahseenam is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    6
    Not sure about that... it's someone else's database that I'm working on. Because of that what I really want to do is more along the lines of a find & replace.

    I guess what I really want is just to go through each object on this report, look at the control source, and find anywhere it says [My Report Name], replace it with [My New Report Name]. So I just need help to write VBA code that will do that.

    So the control sources for all the examples I just gave would now look like:


    =[Reports]![My New Report Name]![Student Total]


    =[Reports]![My New Report Name]![Students Classroom Number]


    =[Reports]![My New Report Name]![Students Section Count]


    =[Reports]![My New Report Name]![Teachers Count]

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Here is an Example, maybe you can modify to suit your needs. Else, let the person whose db it is find a solution!
    'Change Label Names in All Reports:
    For Each obj In Application.CurrentProject.AllReports
    DoCmd.OpenReport Obj.Name, acViewDesign
    if Obj.LabelName.Caption = "XXXXX" Then Obj.LabelName.Caption = "ZZZZZ"




    DoCmd.Close acReport, obj.Name, acSaveYes
    Next obj

    Good Luck With Someone Else's Project!

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Why are textboxes on report referencing fields of another report?

    If you want to do search and replace to change design elements, code would open object in design view, loop through its controls, use Replace function on the ControlSource property, close object with changes saved. An alternative is to acquire third party add-in. I use Rick Fisher's Find & Replace for Access. Saved my sanity more than once, well worth the $50.
    Last edited by June7; 10-05-2014 at 10:28 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  2. Replies: 5
    Last Post: 04-01-2013, 11:49 AM
  3. Replies: 3
    Last Post: 02-07-2013, 09:53 PM
  4. Automatically Update References
    By dandoescode in forum Programming
    Replies: 13
    Last Post: 06-28-2012, 10:14 AM
  5. Update Two fields (text boxes) Form
    By j2curtis64 in forum Forms
    Replies: 11
    Last Post: 07-06-2011, 08:43 AM

Tags for this Thread

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