Results 1 to 4 of 4
  1. #1
    Gary is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    14

    Cycle Text Boxes with a For next loop

    hey all,

    I am using a macro to compare several textboxes on a form when a check box on a subform is clicked.


    my code is:


    For i = 1 To 8

    box1 = "System Improvements Target #" & CStr(i)
    box2 = "System Improvements #" & CStr(i)
    If Not IsNull(Forms![Major Breakdowns]!Controls(box1)) Then
    If IsNull(Forms![Major Breakdowns]!Controls(box2)) Then
    MsgBox "Please fill in all actual dates for targets"
    Me.bd_MajorReported.Value = False
    End If
    End If
    Next


    where box1 and box2 are reset to the name of a different text box on the main form, i.e. System Improvements Target #1" System Improvements Target #2" etc. based on i.



    the issue is that VBA is not recognizing Forms![Major Breakdowns]!Controls(box1) that I am looking for the value of the text that has the name of the string box1


    thanks in advance

    Gary

  2. #2
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    Quote Originally Posted by Gary View Post
    hey all,

    I am using a macro to compare several textboxes on a form when a check box on a subform is clicked.


    my code is:


    For i = 1 To 8

    box1 = "System Improvements Target #" & CStr(i)
    box2 = "System Improvements #" & CStr(i)
    If Not IsNull(Forms![Major Breakdowns]!Controls(box1)) Then
    If IsNull(Forms![Major Breakdowns]!Controls(box2)) Then
    MsgBox "Please fill in all actual dates for targets"
    Me.bd_MajorReported.Value = False
    End If
    End If
    Next


    where box1 and box2 are reset to the name of a different text box on the main form, i.e. System Improvements Target #1" System Improvements Target #2" etc. based on i.

    the issue is that VBA is not recognizing Forms![Major Breakdowns]!Controls(box1) that I am looking for the value of the text that has the name of the string box1


    thanks in advance

    Gary
    Is [Major Breakdowns] the name for the sub form?

    If yes, then try this:

    Code:
     
    If Not IsNull(Me.[Major Breakdowns].form![box1]) Then

    Hope this helps ...

    Boyd Trimmell aka HiTechCoach
    Microsoft Access MVP

  3. #3
    Gary is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    14
    Hi Boyd,

    sorry it took so long for me to get back. I tried this method, but the problem is that I was trying to cycle through the controls on my main form from a sub on my sub form. the issue was that the control sources for both were tables. and the check on my subform was linked to a value that was unrelated between the two tables. I ended up removing the subform and replacing the source with a query that included all the values of my main form as well as the one value that was sontrolled by the check box on my subform.

    Thanks for your help!

  4. #4
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    Glad to hear you got it working!
    Boyd Trimmell aka Hitechcoach
    Database Architect and Problem Solver
    Microsoft MVP - Access Expert
    25+ years specializing in Accounting, Inventory, and CRM systems
    "If technology doesn't work for people, then it doesn't work."

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

Similar Threads

  1. characters in text boxes
    By Matthieu in forum Access
    Replies: 0
    Last Post: 04-08-2010, 11:02 AM
  2. Replies: 2
    Last Post: 03-30-2010, 05:08 PM
  3. Cycle Time
    By Dargo in forum Forms
    Replies: 5
    Last Post: 02-26-2009, 05:14 AM
  4. joining text in text boxes
    By jjwilliams73 in forum Forms
    Replies: 1
    Last Post: 08-26-2008, 02:30 PM
  5. bounding text boxes
    By nosirrah69 in forum Database Design
    Replies: 2
    Last Post: 02-23-2006, 08:35 AM

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