473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Loop then string form responses

tuxalot
200 100+
Greeting all -

I have 36 controls on a form, arranged like so:

chkA1 chkA2 txtA3
chkB1 chkB2 txtB3
chkC1 chkC2 txtC3

The functionality of the checkboxes (columns 1 & 2) and textbox (column 3) is like this. A double-click in a textbox on my main form opens this form. All column 2 & 3 controls are visible = false on form load. If a user checks the checkbox in column A1, the checkbox in the same row, column A2 becomes visible. If checkbox A2 is checked, testbox A3 is visible, and so on. There is a default value in the column 3 textboxes, but a user can override this text. This part is working.

So depending on a user's selections, I need a string to be placed in the calling textbox that would show:

If column 2 is not checked:

The string would consist of A1; B1; C1 etc.

If column 2 is checked:

The string would consist of A1, A3; B1, B3; C1, C3 etc.

Most likely there will be a mix of columns 1 & 2 being checked and not checked. So a possible scenario could be:

A1; B1, B3; D1, F1, G1, G3; H1.

So the thinking in my pea-brain is that I use a tag value to interate through the controls on the form (first row would share the same tag value, etc.) and build the string using if then statements. The resulting string should be placed back into the calling textbox. Would this be the best approach? Please help me understand the preferred method to use to get where I need to go with this. Any sample code is very much appreciated.

Thanks again for the assistance.

Tux
Aug 30 '11 #1
9 1675
NeoPa
32,556 Expert Mod 16PB
Although this is a pretty decent job of explaining a quite complex situation, you've made a mistake somewhere, it seems to me, and what we have doesn't make logical sense. As it's well explained otherwise though, let's see if we can recover it somehow.

You tell me which of the statements below are true and which are false and I'm sure we can help you :
  1. There are 36 unbound controls on your form arranged as three columns and twelve rows.
  2. Columns one and two are both CheckBox controls and start as False.
  3. Column three is a TextBox control.
  4. By default the column three TextBox contains a value that we don't know (please provide - even a dummy one just to work with would be fine) but this can be overridden if made visible.
  5. Columns two and three start as invisible when the form is opened.
  6. The CheckBox in column two is visible when the CheckBox in column one is True.
  7. The TextBox in column three is visible when the CheckBox in column two is True (which can only be the case if the CheckBox in column one is also True).
  8. In the result string the row values are separated by "; " (semi-colon).
  9. In the result string multiple values within a row are separated by ", " (comma).
  10. Resultant string required (just using three rows for simplicity) :
    1. If the reference is required rather than the value :
      Expand|Select|Wrap|Line Numbers
      1. Control Values                  Resultant String
      2. A1=False, A2=False, A3=""
      3. B1=False, B2=False, B3=""
      4. C1=False, C2=False, C3=""       "A1; B1; C1"
      5. A1=False, A2=False, A3=""
      6. B1=True,  B2=False, B3=""
      7. C1=True,  C2=True,  C3="Dummy"  "A1; B1; C1, C3"
      8. A1=True,  A2=True,  A3="Dummy"
      9. B1=True,  B2=True,  B3="Dummy"
      10. C1=True,  C2=True,  C3="Dummy"  "A1, A3; B1, B3; C1, C3"
    2. If the value is required rather than the reference (For now any visible TextBox contains "Dummy") :
      Expand|Select|Wrap|Line Numbers
      1. Control Values                  Resultant String
      2. A1=False, A2=False, A3=""
      3. B1=False, B2=False, B3=""
      4. C1=False, C2=False, C3=""       "False; False; False"
      5. A1=False, A2=False, A3=""
      6. B1=True,  B2=False, B3=""
      7. C1=True,  C2=True,  C3="Dummy"  "False; True; True, Dummy"
      8. A1=True,  A2=True,  A3="Dummy"
      9. B1=True,  B2=True,  B3="Dummy"
      10. C1=True,  C2=True,  C3="Dummy"  "True, Dummy; True, Dummy; True, Dummy"
  11. There is no reason to have column 2 in this scenario (The only possible reason it makes a difference is in the second example of the set where values are shown where it allows B1 to be True without displaying B3).
Aug 30 '11 #2
tuxalot
200 100+
Thanks NeoPa for your response. I will try to clarify. About your list being true or false; A - I are all true. Let me step back to give you an idea about the purpose of this form. I've attached a screenshot. The form will be used to select staff at a hotel that have taken part in a recent survey. Per the choices selected in the example screenshot, the resulting string would be:

Tom Smith; Bob Jones, Director of Food and Beverage; Tim Allan, Asst Director of Food and Beverage.

Default values in the textbox represent the staff members' title at the hotel. In the case of Tim Allan, the default value would be "What is this person's title?"

I apologize for not providing full details earlier. I hope this makes sense.

Attached Images
File Type: jpg screen.jpg (42.8 KB, 456 views)
Aug 30 '11 #3
ADezii
8,834 Expert 8TB
@tuxalot: A rather interesting and perplexing problem. Here is how I approached this scenario, at least partially.
  1. Set the Tag property of all the Check Boxes in Column 1 to 'Col1'.
  2. Set the Tag property of all the Check Boxes in Column 2 to 'Col2'.
  3. Create a Sub-Routine Procedure, called from the AfterUpdate() Event of the Check Boxes in Column 1 that will control the Visibility of Column 2 and Column 3 Controls.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub MakeVisible()
    2. Dim ctl As Control
    3.  
    4. For Each ctl In Me.Controls
    5.   If ctl.Tag = "Col1" Then
    6.     'Check the Value of the Check Boxes in Column 1, then Set the Visible
    7.     'Property of Column 2 Check Boxes and Column 3 Text Boxes accordingly
    8.     Me.Controls(Left$(ctl.Name, 4) & "2").Visible = Nz(ctl.Value)
    9.     Me.Controls("txt" & Mid$(ctl.Name, 4, 1) & "3").Visible = Nz(ctl.Value)
    10.   End If
    11. Next
    12. End Sub
    Expand|Select|Wrap|Line Numbers
    1. 'Sample Call:
    2. Private Sub chkB1_AfterUpdate()
    3.   Call MakeVisible
    4. End Sub
  4. Create a Sub-Routine Procedure, called from the AfterUpdate() Event of the Column 2 Check Boxes, which will dynamically create the requested String:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub BuildString()
    2. Dim ctl As Control
    3. Dim strBuild As String
    4.  
    5. Me![txtResults] = ""
    6.  
    7. For Each ctl In Me.Controls
    8.   If ctl.Tag = "Col2" Then
    9.     If ctl.Value Then       'Column 2 is Checked, build String accordingly
    10.       strBuild = strBuild & Mid$(ctl.Name, 4, 1) & "1," & Mid$(ctl.Name, 4, 1) & "3;"
    11.     Else                    'Column 2 is NOT Checked, build String accordingly
    12.       strBuild = strBuild & Mid$(ctl.Name, 4, 1) & "1;"
    13.     End If
    14.   End If
    15. Next
    16.  
    17. Me![txtResults] = Left$(strBuild, Len(strBuild) - 1)
    18. End Sub
    Expand|Select|Wrap|Line Numbers
    1. 'Sample Call:
    2. Private Sub chkC2_AfterUpdate()
    3.   Call BuildString
    4. End Sub
  5. Download the Attachment to see first hand this approach. I'm sure that it is not comprehensive, but hopefully it is at least in the ballpark.
Attached Files
File Type: zip Check Boxes.zip (24.6 KB, 78 views)
Aug 30 '11 #4
NeoPa
32,556 Expert Mod 16PB
I'm disappointed. Your original description is not only different from the picture shown, but is also so incompatible that all the details of the logic previously worked out are not applicable any more. Sixteen rows instead of twelve is barely a problem. More controls per line doesn't need to be a problem, but as the Staff TextBox wasn't even mentioned and it seems clear (if I ignore your description and look at the picture instead) that having any content there triggers whether or not the Name CheckBox is even visible, this is such a fundamental change to the logic that trying to explain anything within that context impossible.

Simplifying is all well and good, and I don't generally have an issue with that, but when it's done inconsistently then it makes the whole question meaningless (or worse actually - impossible).

Is the picture posted what we should actually be concentrating on? If so, a description of the logic that makes sense in that situation would be useful.

PS. There's no longer any need to respond to point K as this is no longer relevant. The confusion there was part of the larger confusion as to why the question didn't make a lot of sense.
Aug 30 '11 #5
tuxalot
200 100+
@NeoPa - Point taken. If I may, allow me to start from square one. The picture is far superior to my explanation so I will begin there. The textboxes under "Staff" are bound to textboxes on my main form and these controls are locked. The checkboxes under "Name" are visible on form load. The checkboxes under "Title", and the textboxes under "Please include title" are not visible on load. I've attached a screenshot of the main form. The lower left textbox on my main form is double clicked, opening the select staff form. Based on those selections,the string is returned to the calling textbox in the format previously mentioned.

** Edit **

Attached Images
File Type: jpg main form.jpg (26.5 KB, 598 views)
Aug 31 '11 #6
NeoPa
32,556 Expert Mod 16PB
As binding TextBoxes on one form to TextBoxes on another isn't possible, perhaps you could explain what you thought you were saying when you said they were so bound.

I think we're nearly at a point where we can start to look at this seriously.
Aug 31 '11 #7
tuxalot
200 100+
I appreciate your patience. The textboxes in the select staff form are bound and get their data from a query. No, they are not bound to the main form and this was a poor choice of words.

What I am trying to avoid is having to type the same details twice in different areas of my main form; other forms have a similar requirement. Per the image in post #5, There is a name listed for General Manager, Engineering, etc. During the survey, some of the hotel staff participate in the survey and those individuals are named in the box at the lower left of the aforementioned image. In this textbox, the persons name and title are shown, on another form it will just be a listing of names separated by a semi-colon.
Aug 31 '11 #8
NeoPa
32,556 Expert Mod 16PB
Tuxalot (From post #3):
A - I are all true.
Point A was that all controls were unbound. How can I possibly help you if I cannot rely on what you say. I feel like I'm drowning in quicksand. Every time you post anything you contradict one or more points from previous posts. I think we need to get focused here pretty soon or this thread will die a death. I don't think you're actually trying to mess me around, but I do think you're doing a pretty poor job of avoiding it.
Aug 31 '11 #9
tuxalot
200 100+
I am trying to learn Access and I thought this was a place I could get some help. My last post, was that helpful?
Aug 31 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Kamilche | last post by:
I was looking for a way to speed up detecting invalid characters in my TCP string, and thought of yet another use for the translate function! If you were to 'translate out' the bad characters, and...
1
by: Jeremy Langworthy | last post by:
Hi I have a dynamicly generated form (well the elements are at least) that looks something like this: while( not end of returned records): <input name="plan_id" type="checkbox" id=""...
2
by: Brett | last post by:
The following code will allow me to loop through FORM tags but not the elements in them. I may have five forms on one page. How do I loop through form elements in the forth FORM? private...
8
by: AFN | last post by:
I want to have a routine in a page base class that will take all the text fields on a web form, and then HtmlEncode their values. I'm having trouble figuring out if I want to loop controls or...
9
by: wreed | last post by:
I have a for loop seen below.... var the_form = document.getElementById(formName); for(var i=0; i<the_form.length; i++) { var temp = the_form.elements.type; if (temp == "radio") { for (x =...
1
yoda
by: yoda | last post by:
Sorry Ben3eeE about that i'm not very good at programming and i'm in high school I just want to know how to loop a form without the message box.
3
by: Energizer100 | last post by:
Hey. I'm new to Java and I'm trying to make a grades program for a class assignment. This is what I have so far. import java.util.Scanner; import static java.lang.System.out; public class...
2
by: Trevor2007 | last post by:
I have a subform with a loop to check to make sure 1 of the values in the textbox = "N/A" before saving, but I can't seem to finish it, , well get it just to check for 1 N/A value, here is what I...
2
by: SyGC | last post by:
Hey All, im trying to simply display an image depending on whether a text box has been populated or not. To do this im using the String.IsNullOrEmpty(My String) approach. Becuase the image...
1
by: Lelu | last post by:
Hi, My HTML form is generating some blank email responses; does anyone see anything wrong with the scripts?: function isFormVarExcluded(thisForm, strToCheck) { var strExcludeVars =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.