473,480 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DAO Recordset Nested Loops

9 New Member
I'm probably going off in the wrong direction, so feel free to offer other suggestions here.

Overview: I need to look at a common field in two tables and find where they are equal. When equal, I need to UPDATE another table with a value, and when not equal, I need to UPDATE that table with a different value.

Details: The first table is tblKidCharges and the second table is tblTeach. Both tables contain the field FamilyID. When both a child and his parent (the Teacher) are present, their family should receive a $0.00 charge that day. However, if the child is present and the parent is not present, the family will receive a $15.00 charge.

Work Thus Far: I figure this will be done with 2 recordsets. I have experimented with cycling through the recordsets to find where they are equal, but I can't get them to then UPDATE the table (tblCharges).

Any thoughts would be greatly appreciated!
Nov 21 '07 #1
28 3682
ADezii
8,834 Recognized Expert Expert
I'm probably going off in the wrong direction, so feel free to offer other suggestions here.

Overview: I need to look at a common field in two tables and find where they are equal. When equal, I need to UPDATE another table with a value, and when not equal, I need to UPDATE that table with a different value.

Details: The first table is tblKidCharges and the second table is tblTeach. Both tables contain the field FamilyID. When both a child and his parent (the Teacher) are present, their family should receive a $0.00 charge that day. However, if the child is present and the parent is not present, the family will receive a $15.00 charge.

Work Thus Far: I figure this will be done with 2 recordsets. I have experimented with cycling through the recordsets to find where they are equal, but I can't get them to then UPDATE the table (tblCharges).

Any thoughts would be greatly appreciated!
  1. Kindly post the Field Names and their Data Tyeps in tblKidCharges, tblTeach, and tblCharges.
  2. List any Relationships among the Tables and the Keys involved, along with their Data Types.
  3. Define the conditions under which a Child could be present in tblKidCharges and a Parent would also be present in tblTeach.
  4. What condition would indicate that a Child was present in tblKidCharges and his/her Parent wasn't in tblTeach?
  5. How would you know the specific Record to Update in tblCharges? [FamilyID]?
Nov 21 '07 #2
Quiver
9 New Member
  1. Kindly post the Field Names and their Data Tyeps in tblKidCharges, tblTeach, and tblCharges.
  2. List any Relationships among the Tables and the Keys involved, along with their Data Types.
  3. Define the conditions under which a Child could be present in tblKidCharges and a Parent would also be present in tblTeach.
  4. What condition would indicate that a Child was present in tblKidCharges and his/her Parent wasn't in tblTeach?
  5. How would you know the specific Record to Update in tblCharges? [FamilyID]?
1)
tblKidCharges
KidBatchID (AutoNumber)
BatchID (Number)
ChildID (Number)
Dte (Date/Time)
FamilyID (Number)
LName (Text)
Group (Text)

tblTeach
TeachBatchID (AutoNumber)
BatchID (Number)
FamilyID (Number)
Dte (Date/Time)
FamilyLName (Text)

tblCharges
BatchID (Number)
Dte (Date/Time)
ChildID (Number)
DateStamp (Date/Time)
RateID (Number)
FamilyID (Number)

2)
There are no relationships currently between these tables, but there is a one-to-many between tblFamily and tblKids that link by the FamilyID.

3) & 4)
The data ends up in tblKidCharges and tblTeach by way of 2 multi-select listboxes on frmMAIN. When "charges" are being entered, the user will choose all of the kids present, and then all of the teachers present. A teacher will rarely be present if her children are not, but kids may be present without their teacher/parent being present. When a teacher is present, all of her kids that are also present that day are not charged for the day.

5)
I am envisioning that the charges will ultimately be posted to tblCharges along with the rate that was charged. I don't want the user to have to choose a rate. I want the single click of a button on frmMAIN to take all of the kids and teachers present that day (from the list boxes) and put them in their respective tables. Then begin the process of looking for kids who have their parent/teacher also present, so that the $0.00 rate can be chosen, and subsequently appending that data to tblCharges. I would then like to take the remaining kids, and charge them the rate that is detailed in tblRates (I'm pretty sure I have this step covered).


I hope that clears things up. Let me know if you need more info.

Thanks for your help!
Nov 21 '07 #3
ADezii
8,834 Recognized Expert Expert
1)
tblKidCharges
KidBatchID (AutoNumber)
BatchID (Number)
ChildID (Number)
Dte (Date/Time)
FamilyID (Number)
LName (Text)
Group (Text)

tblTeach
TeachBatchID (AutoNumber)
BatchID (Number)
FamilyID (Number)
Dte (Date/Time)
FamilyLName (Text)

tblCharges
BatchID (Number)
Dte (Date/Time)
ChildID (Number)
DateStamp (Date/Time)
RateID (Number)
FamilyID (Number)

2)
There are no relationships currently between these tables, but there is a one-to-many between tblFamily and tblKids that link by the FamilyID.

3) & 4)
The data ends up in tblKidCharges and tblTeach by way of 2 multi-select listboxes on frmMAIN. When "charges" are being entered, the user will choose all of the kids present, and then all of the teachers present. A teacher will rarely be present if her children are not, but kids may be present without their teacher/parent being present. When a teacher is present, all of her kids that are also present that day are not charged for the day.

5)
I am envisioning that the charges will ultimately be posted to tblCharges along with the rate that was charged. I don't want the user to have to choose a rate. I want the single click of a button on frmMAIN to take all of the kids and teachers present that day (from the list boxes) and put them in their respective tables. Then begin the process of looking for kids who have their parent/teacher also present, so that the $0.00 rate can be chosen, and subsequently appending that data to tblCharges. I would then like to take the remaining kids, and charge them the rate that is detailed in tblRates (I'm pretty sure I have this step covered).


I hope that clears things up. Let me know if you need more info.

Thanks for your help!
Quiver, I must admit that I am having a difficult time following your logic, and I do believe that it is a little unorthodox, but let's take it 1 step at a time.
  1. tblKidsCharges will be populated via multiple selections made from a Combo Box on frmMain. This Combo Box must then display all the Fields in tblKidCharges except Date. If this is true:
    1. What is the Name of the Combo Box?
    2. What is the Row Source for the Combo Box?
    3. How many Columns are there in the Combo Box (displayed and non-displayed)?
    4. What are the Column Widths (basically same question as previous)?
    5. Does the Combo Box have a Control Source? If so, what is it?
    6. Does the Combo Box have a Bound Field? If so, what is it?
  2. Forget tblTeach and tblCharges for now. If the User makes 4 Kid selections from the Combo Box, you would then want a Button Click() to write 4 Records to tblKidCharges, correct?
  3. Fill in the missing blanks, and we'll take it from there.
Nov 22 '07 #4
BradHodge
166 Recognized Expert New Member
Quiver, I must admit that I am having a difficult time following your logic, and I do believe that it is a little unorthodox, but let's take it 1 step at a time.
  1. tblKidsCharges will be populated via multiple selections made from a Combo Box on frmMain. This Combo Box must then display all the Fields in tblKidCharges except Date. If this is true:
    1. What is the Name of the Combo Box?
    2. What is the Row Source for the Combo Box?
    3. How many Columns are there in the Combo Box (displayed and non-displayed)?
    4. What are the Column Widths (basically same question as previous)?
    5. Does the Combo Box have a Control Source? If so, what is it?
    6. Does the Combo Box have a Bound Field? If so, what is it?
  2. Forget tblTeach and tblCharges for now. If the User makes 4 Kid selections from the Combo Box, you would then want a Button Click() to write 4 Records to tblKidCharges, correct?
  3. Fill in the missing blanks, and we'll take it from there.
If I could count the number of times my wife has said she was having trouble following my logic :)


1a) The selections on frmMAIN are actually made from List Boxes. The one for the kids is ListKids and is made up of 3 columns (ChildID, LName and FName) with Child ID being bound and invisible to the user.

The one for the teachers is ListTeach and is made up of 4 columns (FamilyID, FamilyLName, MomFName and TeacherSub(this is a parameter column that just narrows the lists to those parents that are either parents or subs)). FamilyID is the bound column and also invisible.

1b) The Row Source for ListKids is tblKids.

1c) See 1a

1d) The exact column widths are ListKids: 0";0.625";0.6771" and ListTeach: 0"; 0.625";0.6771";0"

1e) Neither List Box has a Control Source

1f) See 1a

2) This is the code that writes the records to tblKidCharges
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL as String
  2. Dim strSQL2 as String
  3. Dim strSQL3 as String
  4. Dim ctl as Control
  5. DoCmd.SetWarnings False
  6.     Set ctl = Forms![frmMain]![ListKids]
  7.     strSQL = "INSERT INTO tblKidCharges (BatchID, ChildID, Dte) VALUES("
  8.     strSQL = strSQL & Me.BatchID & ", "
  9.     strSQL2 = Me.txtDate & "#"
  10.     For Each varItem In ctl.ItemsSelected
  11.         strSQL3 = strSQL & ctl.ItemData(varItem) & ", #" & strSQL2 & ");"
  12.         CurrentDb.Execute strSQL3
  13.     Next varItem
  14.     DoCmd.RunSQL "UPDATE tblKidCharges LEFT JOIN tblKids ON tblKidCharges.childID = tblKids.ChildID " _
  15.                     & "SET tblKidCharges.FamilyID = tblKids.FamilyId, tblKidCharges.LName = " _
  16.                     & "tblKids.LName, tblKidCharges.[Group] = tblKids.Group;"
  17.     DoCmd.SetWarnings True
3) In case it helps, the related tables are as follows:

tblFamily
FamilyID (Number)
FamilyLName (Text)
DadFName (Text)
MomFName (Text)
TeacherSub (Text) --Can have value of Null, Teacher or Sub

tblRates
RateID (Number)
RateDescrip (Text)
Rate (Currency)


Thanks for your time on this. I will be interested in hearing your thoughts even if it's to scrap this design and head off in a different direction :)
Nov 22 '07 #5
BradHodge
166 Recognized Expert New Member
If I could count the number of times my wife has said she was having trouble following my logic :)


1a) The selections on frmMAIN are actually made from List Boxes. The one for the kids is ListKids and is made up of 3 columns (ChildID, LName and FName) with Child ID being bound and invisible to the user.

The one for the teachers is ListTeach and is made up of 4 columns (FamilyID, FamilyLName, MomFName and TeacherSub(this is a parameter column that just narrows the lists to those parents that are either parents or subs)). FamilyID is the bound column and also invisible.

1b) The Row Source for ListKids is tblKids.

1c) See 1a

1d) The exact column widths are ListKids: 0";0.625";0.6771" and ListTeach: 0"; 0.625";0.6771";0"

1e) Neither List Box has a Control Source

1f) See 1a

2) This is the code that writes the records to tblKidCharges
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL as String
  2. Dim strSQL2 as String
  3. Dim strSQL3 as String
  4. Dim ctl as Control
  5. DoCmd.SetWarnings False
  6.     Set ctl = Forms![frmMain]![ListKids]
  7.     strSQL = "INSERT INTO tblKidCharges (BatchID, ChildID, Dte) VALUES("
  8.     strSQL = strSQL & Me.BatchID & ", "
  9.     strSQL2 = Me.txtDate & "#"
  10.     For Each varItem In ctl.ItemsSelected
  11.         strSQL3 = strSQL & ctl.ItemData(varItem) & ", #" & strSQL2 & ");"
  12.         CurrentDb.Execute strSQL3
  13.     Next varItem
  14.     DoCmd.RunSQL "UPDATE tblKidCharges LEFT JOIN tblKids ON tblKidCharges.childID = tblKids.ChildID " _
  15.                     & "SET tblKidCharges.FamilyID = tblKids.FamilyId, tblKidCharges.LName = " _
  16.                     & "tblKids.LName, tblKidCharges.[Group] = tblKids.Group;"
  17.     DoCmd.SetWarnings True
3) In case it helps, the related tables are as follows:

tblFamily
FamilyID (Number)
FamilyLName (Text)
DadFName (Text)
MomFName (Text)
TeacherSub (Text) --Can have value of Null, Teacher or Sub

tblRates
RateID (Number)
RateDescrip (Text)
Rate (Currency)


Thanks for your time on this. I will be interested in hearing your thoughts even if it's to scrap this design and head off in a different direction :)

One more piece of info...

My initial thoughts were to begin the append to tblCharges from frmMAIN (instead of doing the interim append to tblKidCharges and tblTeach). It seems like this would be the more straight forward approach, but I couldn't figure out how to loop through the List Boxes to evaluate the selections, and determine which kids had their parent/teachers present as well.

Incase that's of any benefit.

Thanks again.
Nov 23 '07 #6
ADezii
8,834 Recognized Expert Expert
If I could count the number of times my wife has said she was having trouble following my logic :)


1a) The selections on frmMAIN are actually made from List Boxes. The one for the kids is ListKids and is made up of 3 columns (ChildID, LName and FName) with Child ID being bound and invisible to the user.

The one for the teachers is ListTeach and is made up of 4 columns (FamilyID, FamilyLName, MomFName and TeacherSub(this is a parameter column that just narrows the lists to those parents that are either parents or subs)). FamilyID is the bound column and also invisible.

1b) The Row Source for ListKids is tblKids.

1c) See 1a

1d) The exact column widths are ListKids: 0";0.625";0.6771" and ListTeach: 0"; 0.625";0.6771";0"

1e) Neither List Box has a Control Source

1f) See 1a

2) This is the code that writes the records to tblKidCharges
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL as String
  2. Dim strSQL2 as String
  3. Dim strSQL3 as String
  4. Dim ctl as Control
  5. DoCmd.SetWarnings False
  6.     Set ctl = Forms![frmMain]![ListKids]
  7.     strSQL = "INSERT INTO tblKidCharges (BatchID, ChildID, Dte) VALUES("
  8.     strSQL = strSQL & Me.BatchID & ", "
  9.     strSQL2 = Me.txtDate & "#"
  10.     For Each varItem In ctl.ItemsSelected
  11.         strSQL3 = strSQL & ctl.ItemData(varItem) & ", #" & strSQL2 & ");"
  12.         CurrentDb.Execute strSQL3
  13.     Next varItem
  14.     DoCmd.RunSQL "UPDATE tblKidCharges LEFT JOIN tblKids ON tblKidCharges.childID = tblKids.ChildID " _
  15.                     & "SET tblKidCharges.FamilyID = tblKids.FamilyId, tblKidCharges.LName = " _
  16.                     & "tblKids.LName, tblKidCharges.[Group] = tblKids.Group;"
  17.     DoCmd.SetWarnings True
3) In case it helps, the related tables are as follows:

tblFamily
FamilyID (Number)
FamilyLName (Text)
DadFName (Text)
MomFName (Text)
TeacherSub (Text) --Can have value of Null, Teacher or Sub

tblRates
RateID (Number)
RateDescrip (Text)
Rate (Currency)


Thanks for your time on this. I will be interested in hearing your thoughts even if it's to scrap this design and head off in a different direction :)
I'm headed off to work and have only a couple of minutes to look at this, but the following code should, (hasn't been tested), loop throught all the Selected Items in ListKids and check each Item against ALL Selected Items in ListTeach. If an equality exists between any Item, based on the Bound Column only, you can then take some action. The logic may have to be changed somewhat, but is this basically what you are referring to?
Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form, ctl_1 As Control, ctl_2 As Control
  2. Dim varItm As Variant, varItm_2 As Variant, intI As Integer
  3.  
  4. Set frm = Forms!YourFormName
  5.  
  6. Set ctl_1 = frm!ListKids
  7. Set ctl_2 = frm!ListTeach
  8.  
  9. 'Check every Selected Item in ListKids against every Selected Item in ListTeach
  10. For Each varItm In ctl.ItemsSelected
  11.   For Each varItm_2 In ctl_2.ItemsSelected
  12.     If ctl.ItemData(varItm) = ctl_2.ItemData(varItm_2) Then
  13.       'indicates equality based on the Bound Columns of both List Boxes
  14.     End If
  15.   Next varItm_2
  16. Next varItm
Nov 23 '07 #7
BradHodge
166 Recognized Expert New Member
I'm headed off to work and have only a couple of minutes to look at this, but the following code should, (hasn't been tested), loop throught all the Selected Items in ListKids and check each Item against ALL Selected Items in ListTeach. If an equality exists between any Item, based on the Bound Column only, you can then take some action. The logic may have to be changed somewhat, but is this basically what you are referring to?
Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form, ctl_1 As Control, ctl_2 As Control
  2. Dim varItm As Variant, varItm_2 As Variant, intI As Integer
  3.  
  4. Set frm = Forms!YourFormName
  5.  
  6. Set ctl_1 = frm!ListKids
  7. Set ctl_2 = frm!ListTeach
  8.  
  9. 'Check every Selected Item in ListKids against every Selected Item in ListTeach
  10. For Each varItm In ctl.ItemsSelected
  11.   For Each varItm_2 In ctl_2.ItemsSelected
  12.     If ctl.ItemData(varItm) = ctl_2.ItemData(varItm_2) Then
  13.       'indicates equality based on the Bound Columns of both List Boxes
  14.     End If
  15.   Next varItm_2
  16. Next varItm
That is in the direction that I was headed. It's nice to see the proper way to nest the two (that always throws me).

Since the bound column in ListKids is ChildID and the bound in ListTeach is FamilyID, I can't use it without modifications. I was however thinking of using a DLookUp for the 1st part of the expression to get the applicable FamilyID. Here is what I have so far...
Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form, ctl_1 As Control, ctl_2 As Control
  2. Dim varItm1 As Variant, varItm2 As Variant, intI As Integer
  3. Dim strSQL As String
  4. Dim strSQL2 As String
  5. Dim strFam As String
  6. Dim strTeach As String
  7. Dim strKid As String
  8. Dim strRate, strRate2 As String
  9.  
  10. Set frm = Forms!frmMain
  11. Set ctl_1 = frm!ListKids
  12. Set ctl_2 = frm!ListTeach
  13.  
  14. DoCmd.SetWarnings False
  15.  
  16. For Each varItm1 In ctl_1.ItemsSelected
  17.     For Each varItm2 In ctl_2.ItemsSelected
  18.         strFam = DLookup("FamilyID", "tblKids", "ChildID =" & ctl_1.ItemData(varItm1))
  19.         strTeach = Nz(ctl_2.ItemData(varItm2), 0)
  20.         strRate = DLookup("RateID", "tblRates", "[RateDescrip]= '" & _
  21.                     DLookup("Teacher_Sub", "tblFamily", "[FamilyID]= " & strFam) & "'")
  22.  
  23.             If strFam = strTeach Then
  24.                 DoCmd.RunSQL "INSERT INTO tblCharges (Dte, ChildID, FamilyID, RateID) VALUES (#" & _
  25.                 Me.txtDate & "#, " & ctl_1.ItemData(varItm1) & ", " & strFam & ", " & strRate & ");"
  26.                 strFam = Nz(ctl_2.ItemData(varItm2), 0)
  27.             Else:
  28.                 strRate2 = DLookup("RateID", "tblRates", "[RateDescrip]= '" & _
  29.                 DLookup("Group", "tblKids", "[ChildID]= " & ctl_1.ItemData(varItm1)) & "'")
  30.                 DoCmd.RunSQL "INSERT INTO tblCharges (Dte, ChildID, FamilyID, RateID) VALUES (#" & _
  31.                 Me.txtDate & "#, " & ctl_1.ItemData(varItm1) & ", " & strFam & ", " & strRate2 & ");"
  32.         End If
  33.     Next varItm2
  34. Next varItm1
  35.  
  36. DoCmd.SetWarnings True
Here are the current scenarios...
1) If you select 1 or more children and 1 parent/teacher, they will append
correctly.

2) If you select 2 or more children and 2 or more parent/teachers, the append
will double
- The child with a parent/teacher present will append at $0.00 and then
again at the regular rate.
- The child without a parent/teacher present will append twice at the correct
rate).

3) If you select 1 or more children without any parent/teachers selected, no
append occurs.

Any thoughts?

As always... Thanks!

My apologies for the strange indenting... Couldn't get it look as pretty as I wanted
Nov 23 '07 #8
ADezii
8,834 Recognized Expert Expert
That is in the direction that I was headed. It's nice to see the proper way to nest the two (that always throws me).

Since the bound column in ListKids is ChildID and the bound in ListTeach is FamilyID, I can't use it without modifications. I was however thinking of using a DLookUp for the 1st part of the expression to get the applicable FamilyID. Here is what I have so far...
Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form, ctl_1 As Control, ctl_2 As Control
  2. Dim varItm1 As Variant, varItm2 As Variant, intI As Integer
  3. Dim strSQL As String
  4. Dim strSQL2 As String
  5. Dim strFam As String
  6. Dim strTeach As String
  7. Dim strKid As String
  8. Dim strRate, strRate2 As String
  9.  
  10. Set frm = Forms!frmMain
  11. Set ctl_1 = frm!ListKids
  12. Set ctl_2 = frm!ListTeach
  13.  
  14. DoCmd.SetWarnings False
  15.  
  16. For Each varItm1 In ctl_1.ItemsSelected
  17.     For Each varItm2 In ctl_2.ItemsSelected
  18.         strFam = DLookup("FamilyID", "tblKids", "ChildID =" & ctl_1.ItemData(varItm1))
  19.         strTeach = Nz(ctl_2.ItemData(varItm2), 0)
  20.         strRate = DLookup("RateID", "tblRates", "[RateDescrip]= '" & _
  21.                     DLookup("Teacher_Sub", "tblFamily", "[FamilyID]= " & strFam) & "'")
  22.  
  23.             If strFam = strTeach Then
  24.                 DoCmd.RunSQL "INSERT INTO tblCharges (Dte, ChildID, FamilyID, RateID) VALUES (#" & _
  25.                 Me.txtDate & "#, " & ctl_1.ItemData(varItm1) & ", " & strFam & ", " & strRate & ");"
  26.                 strFam = Nz(ctl_2.ItemData(varItm2), 0)
  27.             Else:
  28.                 strRate2 = DLookup("RateID", "tblRates", "[RateDescrip]= '" & _
  29.                 DLookup("Group", "tblKids", "[ChildID]= " & ctl_1.ItemData(varItm1)) & "'")
  30.                 DoCmd.RunSQL "INSERT INTO tblCharges (Dte, ChildID, FamilyID, RateID) VALUES (#" & _
  31.                 Me.txtDate & "#, " & ctl_1.ItemData(varItm1) & ", " & strFam & ", " & strRate2 & ");"
  32.         End If
  33.     Next varItm2
  34. Next varItm1
  35.  
  36. DoCmd.SetWarnings True
Here are the current scenarios...
1) If you select 1 or more children and 1 parent/teacher, they will append
correctly.

2) If you select 2 or more children and 2 or more parent/teachers, the append
will double
- The child with a parent/teacher present will append at $0.00 and then
again at the regular rate.
- The child without a parent/teacher present will append twice at the correct
rate).

3) If you select 1 or more children without any parent/teachers selected, no
append occurs.

Any thoughts?

As always... Thanks!

My apologies for the strange indenting... Couldn't get it look as pretty as I wanted
I'll take everything into work tomorrow, and hopefully, I will give it a good look and see. I will get back to you as soon as the time allows.
Nov 23 '07 #9
ADezii
8,834 Recognized Expert Expert
That is in the direction that I was headed. It's nice to see the proper way to nest the two (that always throws me).

Since the bound column in ListKids is ChildID and the bound in ListTeach is FamilyID, I can't use it without modifications. I was however thinking of using a DLookUp for the 1st part of the expression to get the applicable FamilyID. Here is what I have so far...
Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form, ctl_1 As Control, ctl_2 As Control
  2. Dim varItm1 As Variant, varItm2 As Variant, intI As Integer
  3. Dim strSQL As String
  4. Dim strSQL2 As String
  5. Dim strFam As String
  6. Dim strTeach As String
  7. Dim strKid As String
  8. Dim strRate, strRate2 As String
  9.  
  10. Set frm = Forms!frmMain
  11. Set ctl_1 = frm!ListKids
  12. Set ctl_2 = frm!ListTeach
  13.  
  14. DoCmd.SetWarnings False
  15.  
  16. For Each varItm1 In ctl_1.ItemsSelected
  17.     For Each varItm2 In ctl_2.ItemsSelected
  18.         strFam = DLookup("FamilyID", "tblKids", "ChildID =" & ctl_1.ItemData(varItm1))
  19.         strTeach = Nz(ctl_2.ItemData(varItm2), 0)
  20.         strRate = DLookup("RateID", "tblRates", "[RateDescrip]= '" & _
  21.                     DLookup("Teacher_Sub", "tblFamily", "[FamilyID]= " & strFam) & "'")
  22.  
  23.             If strFam = strTeach Then
  24.                 DoCmd.RunSQL "INSERT INTO tblCharges (Dte, ChildID, FamilyID, RateID) VALUES (#" & _
  25.                 Me.txtDate & "#, " & ctl_1.ItemData(varItm1) & ", " & strFam & ", " & strRate & ");"
  26.                 strFam = Nz(ctl_2.ItemData(varItm2), 0)
  27.             Else:
  28.                 strRate2 = DLookup("RateID", "tblRates", "[RateDescrip]= '" & _
  29.                 DLookup("Group", "tblKids", "[ChildID]= " & ctl_1.ItemData(varItm1)) & "'")
  30.                 DoCmd.RunSQL "INSERT INTO tblCharges (Dte, ChildID, FamilyID, RateID) VALUES (#" & _
  31.                 Me.txtDate & "#, " & ctl_1.ItemData(varItm1) & ", " & strFam & ", " & strRate2 & ");"
  32.         End If
  33.     Next varItm2
  34. Next varItm1
  35.  
  36. DoCmd.SetWarnings True
Here are the current scenarios...
1) If you select 1 or more children and 1 parent/teacher, they will append
correctly.

2) If you select 2 or more children and 2 or more parent/teachers, the append
will double
- The child with a parent/teacher present will append at $0.00 and then
again at the regular rate.
- The child without a parent/teacher present will append twice at the correct
rate).

3) If you select 1 or more children without any parent/teachers selected, no
append occurs.

Any thoughts?

As always... Thanks!

My apologies for the strange indenting... Couldn't get it look as pretty as I wanted
After taking a closer look at everything, I feel as though your iinitial impression in Post #5 may be correct:
I will be interested in hearing your thoughts even if it's to scrap this design and head off in a different direction
You are working with 4 Independent Tables, 2 Related Tables, and attempting to integrate them all into an Application. There seems to be too many unrelated processes and intermediate steps. Personally, i feel as though a Redesign is in order but I'll call on some of the other Experts/Moderators for their viewpoints on the subject.
Nov 24 '07 #10
nico5038
3,080 Recognized Expert Specialist
I agree with a redesign.
1) Start with defining the needed output like the report "Charges"
2) Use the report fields to reorganize into normalized tables.
3) Design the needed processes and use a form per process like:
Add Child /Update Child/Delete Child
Add Teacher /Update Teacher/Delete Teacher
Record attendance

As far as I see you would need a tblTeacher and a tblChild and for those children with a "teaching parent" a relation table tblTeacherChild. Finally a tblAttendance can be used to record the data for the report.
For the attendance you need to record only the children and add an indication or the parent is a teacher.

When you have multiple groups you might add a "class" table.

Nic;o)
Nov 24 '07 #11
BradHodge
166 Recognized Expert New Member
I agree with a redesign.
1) Start with defining the needed output like the report "Charges"
2) Use the report fields to reorganize into normalized tables.
3) Design the needed processes and use a form per process like:
Add Child /Update Child/Delete Child
Add Teacher /Update Teacher/Delete Teacher
Record attendance

As far as I see you would need a tblTeacher and a tblChild and for those children with a "teaching parent" a relation table tblTeacherChild. Finally a tblAttendance can be used to record the data for the report.
For the attendance you need to record only the children and add an indication or the parent is a teacher.

When you have multiple groups you might add a "class" table.

Nic;o)
Thanks ADezii and Nic;o) for your input. It sounds as if I was at least partially on the right track. My current tables are...

tblKids
tblFamily (which includes an indicator if there is a teacher or sub in the family)
tblTeachers (which runs my List Box)
tblRates (with 2 different class rates, a teacher rate and a sub rate)
tblCharges


A little more info on how everything currently works.
1) The user chooses all kids present and all teachers/subs present from 2 different list boxes on one form.
2) On the click of a button, the app compares ListKids to ListTeachers and appends the appropriate Kids to tblCharges with the ChildID, FamilyID (both from tblKids), the Date (from frmMAIN), and the RateID from the series of DLookups to tblRates.
3) The append is happening, with the exceptions mentioned in the post above
Here are the current scenarios...
1) If you select 1 or more children and 1 parent/teacher, they will append
correctly.
2) If you select 2 or more children and 2 or more parent/teachers, the append
will double
- The child with a parent/teacher present will append at $0.00 and then
again at the regular rate.
- The child without a parent/teacher present will append twice at the correct
rate).
3) If you select 1 or more children without any parent/teachers selected, no
append occurs.
In addition, Nic;o), I do have separate forms for adding families, children and teachers, and all of them are working well.

I would assume that my tables are fairly normalized (although I'm sure that "fairly normalized" is an oxymoron ), and that the fields that I am wanting to input into tblCharges are good fields (mostly ID fields that can I can reference when generating reports).

Am I way off base here?

Thanks!

Brad.
Nov 24 '07 #12
ADezii
8,834 Recognized Expert Expert
I agree with a redesign.
1) Start with defining the needed output like the report "Charges"
2) Use the report fields to reorganize into normalized tables.
3) Design the needed processes and use a form per process like:
Add Child /Update Child/Delete Child
Add Teacher /Update Teacher/Delete Teacher
Record attendance

As far as I see you would need a tblTeacher and a tblChild and for those children with a "teaching parent" a relation table tblTeacherChild. Finally a tblAttendance can be used to record the data for the report.
For the attendance you need to record only the children and add an indication or the parent is a teacher.

When you have multiple groups you might add a "class" table.

Nic;o)
Thanks for the Input, Nico, it is appreciated.
Nov 25 '07 #13
NeoPa
32,556 Recognized Expert Moderator MVP
Brad,

Firstly (on a matter of simple curiosity) I assume that Quiver (OP) is simply a Nom de Plume?

As to the structure of your database. I would agree with Nico's suggestion and just clarify a little something to do with table structures. It's often tempting to organise things such that a relationship you know to exist is reflected in the structure. In this case Teacher & Parent as a single 'Relationship' as many children have that situation in the classroom. These are however, two distinct relationships, and need to be handled separately in a database for it to be able to help you as much as it can (the database that is). Databases aren't as bright as humans so where you or I could handle this extra level of complexity in our brains, for the most part, a database needs extra (more complicated) programming to make sense of this if the two are tied together in a way that is natural for human thought. This is where Normalisation can help. It keeps it all much simpler.

As a second (technical) comment, I find that when I need to doctor any SQL in my applications I use the Replace() function. This way I can use a template set of SQL and replace those items within it which are changeable. As an illustration :
Expand|Select|Wrap|Line Numbers
  1. Private Sub ???
  2.   Dim strSQLTemplate As String
  3.   Dim strSQL as String
  4.   Dim varItem as Variant
  5.  
  6.   DoCmd.SetWarnings False
  7.   strSQLTemplate = "INSERT INTO tblKidCharges " & _
  8.                    "(BatchID, ChildID, Dte) " & _
  9.                    "VALUES(%B, %C, #%D#)"
  10.   strSQLTemplate = Replace(strSQLTemplate, "%B", Me.BatchID)
  11.   strSQLTemplate = Replace(strSQLTemplate, "%C", Me.ChildID)
  12.   For Each varItem In Me.ListKids.ItemsSelected
  13.     strSQL = Replace(strSQLTemplate, "%D", varItem)
  14.     CurrentDb.Execute strSQL3
  15.   Next ctl
  16.   ...
  17.   DoCmd.SetWarnings True
  18. End Sub
As a bonus (in case you're interested) I've written a short function to handle multiple replaces in one go. Feel free to copy and use. I find this invaluable when I have a whole bunch of fields to insert into a template. I also use it for configuring messages to the operator.
Expand|Select|Wrap|Line Numbers
  1. 'MultiReplace replaces all occurrences of varParam in strMain with varReplace.
  2. 'Using VbBinaryCompare means that case is not ignored.
  3. Public Function MultiReplace(ByRef strMain As String, _
  4.                              ByVal varParam As Variant, _
  5.                              ByVal varReplace As Variant, _
  6.                              ParamArray avarArgs())
  7.     Dim intIdx As Integer
  8.  
  9.     If (UBound(avarArgs) - LBound(avarArgs)) Mod 2 = 0 Then Stop
  10.     MultiReplace = Replace(Expression:=strMain, _
  11.                            Find:=Nz(varParam, ""), _
  12.                            Replace:=Nz(varReplace, ""), _
  13.                            Compare:=vbBinaryCompare)
  14.     For intIdx = LBound(avarArgs) To UBound(avarArgs) Step 2
  15.         MultiReplace = Replace(Expression:=MultiReplace, _
  16.                                Find:=Nz(avarArgs(intIdx), ""), _
  17.                                Replace:=Nz(avarArgs(intIdx + 1), ""), _
  18.                                Compare:=vbBinaryCompare)
  19.     Next intIdx
  20. End Function
Nov 26 '07 #14
ADezii
8,834 Recognized Expert Expert
...
As a bonus (in case you're interested) I've written a short function to handle multiple replaces in one go. Feel free to copy and use. I find this invaluable when I have a whole bunch of fields to insert into a template. I also use it for configuring messages to the operator.
Expand|Select|Wrap|Line Numbers
  1. 'MultiReplace replaces all occurrences of varParam in strMain with varReplace.
  2. 'Using VbBinaryCompare means that case is not ignored.
  3. Public Function MultiReplace(ByRef strMain As String, _
  4.                              ByVal varParam As Variant, _
  5.                              ByVal varReplace As Variant, _
  6.                              ParamArray avarArgs())
  7.     Dim intIdx As Integer
  8.  
  9.     If (UBound(avarArgs) - LBound(avarArgs)) Mod 2 = 0 Then Stop
  10.     MultiReplace = Replace(Expression:=strMain, _
  11.                            Find:=Nz(varParam, ""), _
  12.                            Replace:=Nz(varReplace, ""), _
  13.                            Compare:=vbBinaryCompare)
  14.     For intIdx = LBound(avarArgs) To UBound(avarArgs) Step 2
  15.         MultiReplace = Replace(Expression:=MultiReplace, _
  16.                                Find:=Nz(avarArgs(intIdx), ""), _
  17.                                Replace:=Nz(avarArgs(intIdx + 1), ""), _
  18.                                Compare:=vbBinaryCompare)
  19.     Next intIdx
  20. End Function
Hello NeoPa, I'm a little confused on the Stop and Step Statements (Lines 9 and 14). I'm assuming the Step is needed because the Find and Replace Arguments occupy consecutive positions in avarArgs, but the Stop has me confused, probably because it is rare that you see it in action (LOL). If you have a minute, please expand on this.

BTW, thanks for your assistance in this Thread.
Nov 26 '07 #15
NeoPa
32,556 Recognized Expert Moderator MVP
Never a problem my friend :)
You're absolutely right about the Step part. Each turn through the loop processes two parameters. This leads back to the Stop bit too.
Stop is like hitting a breakpoint.
As the only reason for this occurring is a programming error (the code is called incorrectly rather than a problem occurring during normal usage) this is perfect error handling for me. As I design the code I will always be the one who finds this error. This seems to be the most appropriate way to give me the information I need to fix the problem. It's fine to replace it with code you're happier with though. The bread and butter of the procedure is the rest of it anyway.
Nov 26 '07 #16
BradHodge
166 Recognized Expert New Member
Thanks guys for sticking with me on this one. I messed around with a copy of the basic database today at lunch. I did normalize the tblFamily and moved the Teacher/Sub indication to it's own table. It did not change the results any, but I didn't have much time to fool with it.

I'll work with the real database when I get home this evening and let you all know how it's going.

And yes Ade, that is a Nom de Plume that I occasionally use. I just tend to get confused on who I am from day to day :)

Brad.
Nov 26 '07 #17
NeoPa
32,556 Recognized Expert Moderator MVP
I prefer Brad's avatar though ;)

PS. Shame really, as Quiver can ask a question clearly :)
He could have been harvested as an expert in time I would guess :D
Nov 26 '07 #18
ADezii
8,834 Recognized Expert Expert
Thanks guys for sticking with me on this one. I messed around with a copy of the basic database today at lunch. I did normalize the tblFamily and moved the Teacher/Sub indication to it's own table. It did not change the results any, but I didn't have much time to fool with it.

I'll work with the real database when I get home this evening and let you all know how it's going.

And yes Ade, that is a Nom de Plume that I occasionally use. I just tend to get confused on who I am from day to day :)

Brad.
Nom de Plume
Is that French, BradHodge? You Experts/Admins are so refined! (LOL).
Nov 26 '07 #19
ADezii
8,834 Recognized Expert Expert
Never a problem my friend :)
You're absolutely right about the Step part. Each turn through the loop processes two parameters. This leads back to the Stop bit too.
Stop is like hitting a breakpoint.
As the only reason for this occurring is a programming error (the code is called incorrectly rather than a problem occurring during normal usage) this is perfect error handling for me. As I design the code I will always be the one who finds this error. This seems to be the most appropriate way to give me the information I need to fix the problem. It's fine to replace it with code you're happier with though. The bread and butter of the procedure is the rest of it anyway.
Thanks NeoPa for the follow up explanation. It was just intellectual curiosity, nothing else.
Nov 27 '07 #20
NeoPa
32,556 Recognized Expert Moderator MVP
Is that French, BradHodge? You Experts/Admins are so refined! (LOL).
Nom de Plume is just French for Pen Name. They just used it first is all ;)
Oh, and by the way, you're an Expert too if you hadn't noticed :D
Nov 27 '07 #21
ADezii
8,834 Recognized Expert Expert
Nom de Plume is just French for Pen Name. They just used it first is all ;)
Oh, and by the way, you're an Expert too if you hadn't noticed :D
Yea, but that's just my Nom de Plume.
Nov 27 '07 #22
BradHodge
166 Recognized Expert New Member
Okay... I have the problem narrowed down.

Here is the meat of my code...
Expand|Select|Wrap|Line Numbers
  1. For Each varItm1 In ctl_1.ItemsSelected 
  2.     For Each varItm2 In ctl_2.ItemsSelected
  3.         strFam = DLookup("FamilyID", "tblKids", "ChildID =" &
  4.                       ctl_1.ItemData(varItm1))
  5.         strTeach = Nz(ctl_2.ItemData(varItm2), 0)
  6.         strRate = DLookup("RateID", "tblRates", "[RateDescrip]= '" &  
  7.                       DLookup("Teach_Sub", "tblTeachers", "[FamilyID]= " & strFam)
  8.                                    & "'")
  9.  
  10.                 If strFam = strTeach Then
  11.                       DoCmd.RunSQL "INSERT INTO tblCharges (Dte, ChildID,
  12.                                                  FamilyID,RateID) VALUES (#" & Me.txtDate
  13.                                                  & "#, " & ctl_1.ItemData(varItm1) & ", " &
  14.                                                  strFam & ", " & strRate & ");"
  15.                Else:
  16.                strRate2 = DLookup("RateID", "tblRates", "[RateDescrip]= '" & 
  17.                DLookup("Group", "tblKids", "[ChildID]= " & ctl_1.ItemData(varItm1))
  18.                             & "'")
  19.                             DoCmd.RunSQL "INSERT INTO tblCharges (Dte, ChildID,
  20.                                                        FamilyID, RateID) VALUES (#" &  
  21.                                                        Me.txtDate & "#, " &
  22.                                                        ctl_1.ItemData(varItm1) & ", " & strFam &
  23.                                                        ", " & strRate2 & ");"
  24.                End If
  25.     Next varItm2
  26. Next varItm1
I think the problem lies in the If / Then Statement. When it finds a match between the 2 List Boxes, it appends (correctly). But then it goes through another Loop and finds a place that they don't match, and it goes to the Else: append. This would explain this scenario
2) If you select 2 or more children and 2 or more parent/teachers, the append
will double
- The child with a parent/teacher present will append at $0.00 and then
again at the regular rate.
I think it needs a qualifier in the If / Then statement that has it look at tblCharges and make sure that there is not already a record with that ChildID on that Date. It would seem like it needs this both in the If statement and the Else statement. No clue how to do this... Any thoughts???

With regards to
3) If you select 1 or more children without any parent/teachers selected, no append occurs.
I think that this is occurring because it doesn't know what to do with no value in ListTeach. Since multi-select list boxes have Null values by default I can't just us an If IsNull (Me.ListTeach) statement.

Does anyone know how to check to see if no selections have been made from a Multi-Select List Box?

Sincerely,
The Name of the Pen
Nov 27 '07 #23
BradHodge
166 Recognized Expert New Member
#
DoCmd.RunSQL "INSERT INTO tblCharges (Dte, ChildID,#
FamilyID, RateID) VALUES (#" & #
Me.txtDate & "#, " &
#
ctl_1.ItemData(varItm1) & ", " & strFam &
#
", " & strRate2 & ");" #
End If
CURSED FORMATTING!!! :)

B
r

a d .
Nov 27 '07 #24
ADezii
8,834 Recognized Expert Expert
Okay... I have the problem narrowed down.

Here is the meat of my code...
Expand|Select|Wrap|Line Numbers
  1. For Each varItm1 In ctl_1.ItemsSelected 
  2.     For Each varItm2 In ctl_2.ItemsSelected
  3.         strFam = DLookup("FamilyID", "tblKids", "ChildID =" &
  4.                       ctl_1.ItemData(varItm1))
  5.         strTeach = Nz(ctl_2.ItemData(varItm2), 0)
  6.         strRate = DLookup("RateID", "tblRates", "[RateDescrip]= '" &  
  7.                       DLookup("Teach_Sub", "tblTeachers", "[FamilyID]= " & strFam)
  8.                                    & "'")
  9.  
  10.                 If strFam = strTeach Then
  11.                       DoCmd.RunSQL "INSERT INTO tblCharges (Dte, ChildID,
  12.                                                  FamilyID,RateID) VALUES (#" & Me.txtDate
  13.                                                  & "#, " & ctl_1.ItemData(varItm1) & ", " &
  14.                                                  strFam & ", " & strRate & ");"
  15.                Else:
  16.                strRate2 = DLookup("RateID", "tblRates", "[RateDescrip]= '" & 
  17.                DLookup("Group", "tblKids", "[ChildID]= " & ctl_1.ItemData(varItm1))
  18.                             & "'")
  19.                             DoCmd.RunSQL "INSERT INTO tblCharges (Dte, ChildID,
  20.                                                        FamilyID, RateID) VALUES (#" &  
  21.                                                        Me.txtDate & "#, " &
  22.                                                        ctl_1.ItemData(varItm1) & ", " & strFam &
  23.                                                        ", " & strRate2 & ");"
  24.                End If
  25.     Next varItm2
  26. Next varItm1
I think the problem lies in the If / Then Statement. When it finds a match between the 2 List Boxes, it appends (correctly). But then it goes through another Loop and finds a place that they don't match, and it goes to the Else: append. This would explain this scenario

I think it needs a qualifier in the If / Then statement that has it look at tblCharges and make sure that there is not already a record with that ChildID on that Date. It would seem like it needs this both in the If statement and the Else statement. No clue how to do this... Any thoughts???

With regards to
I think that this is occurring because it doesn't know what to do with no value in ListTeach. Since multi-select list boxes have Null values by default I can't just us an If IsNull (Me.ListTeach) statement.

Does anyone know how to check to see if no selections have been made from a Multi-Select List Box?

Sincerely,
The Name of the Pen
Assuming your List Box is named lstTest:
Expand|Select|Wrap|Line Numbers
  1. If Me![lstTest].ItemsSelected.Count = 0 Then
  2.   MsgBox "No Items were selected"
  3. Else
  4.   MsgBox Me![lstTest].ItemsSelected.Count & " Item(s) was/were selected"
  5. End If
Nov 27 '07 #25
BradHodge
166 Recognized Expert New Member
Assuming your List Box is named lstTest:
Expand|Select|Wrap|Line Numbers
  1. If Me![lstTest].ItemsSelected.Count = 0 Then
  2.   MsgBox "No Items were selected"
  3. Else
  4.   MsgBox Me![lstTest].ItemsSelected.Count & " Item(s) was/were selected"
  5. End If
Thanks ADezii, That helps. I would assume that I would just run an If/Then statement like this to assess ListTeach, and then run a separate Append statement if =0, followed by exit sub? Then, if >0, proceed with the other Appends?

If so, this should take care of no append occurring when ListTeach is blank.

Now to figure out the other where Appends are doubling.

Thanks again,
Brad.
Nov 27 '07 #26
ADezii
8,834 Recognized Expert Expert
Thanks ADezii, That helps. I would assume that I would just run an If/Then statement like this to assess ListTeach, and then run a separate Append statement if =0, followed by exit sub? Then, if >0, proceed with the other Appends?

If so, this should take care of no append occurring when ListTeach is blank.

Now to figure out the other where Appends are doubling.

Thanks again,
Brad.
BradHodge, in my opinion, you should never be testing whether or not 2 List Boxes have at least 1 Item selected while you are in a For Each..Next, Do While..Loop, If...End If, etc. scenario. The time for testing these conditions are at the very beginning of the Procedure 'before' entering any of these constructs, as in:
Expand|Select|Wrap|Line Numbers
  1. Dim ctl_1 As ListBox, ctl_2 As ListBox
  2.  
  3. Set ctl_1 = Me!ListKids
  4. Set ctl_2 = Me!ListTeach
  5.  
  6. If ctl_1.ItemsSelected.Count = 0 Then
  7.   'Emphasize no Item selected using color Background, be
  8.   'sure to Reset to White at some point
  9.   ctl_1.SetFocus: ctl_1.BackColor = QBColor(14)
  10.     Exit Sub
  11. ElseIf ctl_2.ItemsSelected.Count = 0 Then
  12.   ctl_2.SetFocus: ctl_2.BackColor = QBColor(14)
  13.     Exit Sub
  14. Else
  15.   'Both List Boxes have at least 1 Item Selected
  16.   'Normal processing would proceed here
  17. End If
Nov 27 '07 #27
BradHodge
166 Recognized Expert New Member
BradHodge, in my opinion, you should never be testing whether or not 2 List Boxes have at least 1 Item selected while you are in a For Each..Next, Do While..Loop, If...End If, etc. scenario. The time for testing these conditions are at the very beginning of the Procedure 'before' entering any of these constructs, as in:
Expand|Select|Wrap|Line Numbers
  1. Dim ctl_1 As ListBox, ctl_2 As ListBox
  2.  
  3. Set ctl_1 = Me!ListKids
  4. Set ctl_2 = Me!ListTeach
  5.  
  6. If ctl_1.ItemsSelected.Count = 0 Then
  7.   'Emphasize no Item selected using color Background, be
  8.   'sure to Reset to White at some point
  9.   ctl_1.SetFocus: ctl_1.BackColor = QBColor(14)
  10.     Exit Sub
  11. ElseIf ctl_2.ItemsSelected.Count = 0 Then
  12.   ctl_2.SetFocus: ctl_2.BackColor = QBColor(14)
  13.     Exit Sub
  14. Else
  15.   'Both List Boxes have at least 1 Item Selected
  16.   'Normal processing would proceed here
  17. End If
That's what I was thinking. I'll work on it and let you know. Thanks so much!
Brad.
Nov 27 '07 #28
BradHodge
166 Recognized Expert New Member
That's what I was thinking. I'll work on it and let you know. Thanks so much!
Brad.
Well... After many revisions, Here is the simplified version. It is essentially based on 3 separate loops.

Loop 1: Assess ListTeach for selected items. If no selected items, then charge the children present based on the Child's Rate.

Loop 2: Compare ListKids.ItemData to ListTeach.ItemData. If it matches, charge the child based on the Teacher's Rate.

Loop 3: Compare ListKids.ItemData to tblCharges. If the child has already been charged that day, go to the next ListKids.ItemData. Compare ListKids.ItemData to ListTeach.ItemData. If no match, charge the child based on the Child's Rate.

It is working well. I am betting though that I could have simplified my code by using an Array; but I'll have to save that for another day.

Thanks all for your help!

Brad.
Nov 29 '07 #29

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

Similar topics

25
12660
by: chad | last post by:
I am writing a program to do some reliability calculations that require several nested for-loops. However, I believe that as the models become more complex, the number of required for-loops will...
6
2548
by: Andy Baker | last post by:
Hi there, I'm learning Python at the moment and trying to grok the thinking behind it's scoping and nesting rules. I was googling for nested functions and found this Guido quote:...
0
1777
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # David Eppstein of the Geometry Junkyard fame gave this elegant # version for returing all possible pairs from a range of n numbers. def combo2(n): return...
46
9863
by: Neptune | last post by:
Hello. I am working my way through Zhang's "Teach yourself C in 24 hrs (2e)" (Sam's series), and for nested loops, he writes (p116) "It's often necessary to create a loop even when you are...
77
5148
by: Peter Olcott | last post by:
http://www.tommti-systems.de/go.html?http://www.tommti-systems.de/main-Dateien/reviews/languages/benchmarks.html The above link shows that C# is 450% slower on something as simple as a nested loop....
9
2826
by: Gregory Petrosyan | last post by:
I often make helper functions nested, like this: def f(): def helper(): ... ... is it a good practice or not? What about performance of such constructs?
5
3105
by: =?Utf-8?B?QUEyZTcyRQ==?= | last post by:
Could someone give me a simple example of nested scope in C#, please? I've searched Google for this but have not come up with anything that makes it clear. I am looking at the ECMA guide and...
4
2318
by: toddlahman | last post by:
I am using two while loops that are nested. The first loop (post name) returns the full column of results, but the second (post modified) only returns the first row of the column. Is there another...
13
2677
by: Fredrik Lundh | last post by:
Patrol Sun wrote: so why exactly are you trying to nest 20 or 100 for-in loops? </F>
8
7232
by: Nathan Sokalski | last post by:
I have several nested For loops, as follows: For a As Integer = 0 To 255 For b As Integer = 0 To 255 For c As Integer = 0 To 255 If <Boolean ExpressionThen <My CodeElse Exit For Next If Not...
0
7048
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,...
1
6743
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
6966
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4787
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...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2988
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.