Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Infinite Loop In adding/updating function

Status
Not open for further replies.

Direwolf49

Technical User
Jun 29, 2004
3
US
I'm Not Sure Why, But all of the sudden my code Is not Working For my database. I'm using code to get cummulative area for a given circuit. The user selects the circuit name, and the conductor to add to that circuit, and it adds the information to a list containing an ID field, CircuitName field, and Area Field. Every time they add a wire to the circuit, they really just add a field with the area the wire(cross section) and the name of the circuit. I then added code to the button to read those records from a previously unbound subform, search for any entry containing the name of a circuit, adds the area to the total, and then looks for the entry on the total area database and changes it, or really deletes it and creates a new one. It then jumps to the next circuit and repeats the process. The Problem is that When it gets to the loop used to catch all of the circuits, it goes forever. I used a DO While .EOF = False Loop, and before the Loop Statement, i used the .MoveNext Method. This should just move it untill the file is at an end. If you could shed some light, i'd very much appriciate it. THank You.

Me.frmUtility.Form.RecordSource = "tblCircuit"
Me.frmUtility.Form.Recordset.MoveFirst
Me.frmSubConduit.Form.RecordSource = "tblAssignConductorToCircuit"
Me.frmSubConduit.Form.Recordset.MoveFirst
Do While Me.frmUtility.Form.Recordset.EOF = False
strCircuitName = Me.Recordset.Fields("CircuitName").Value
Me.frmSubConduit.Form.Recordset.MoveFirst
Do While Me.frmSubConduit.Form.Recordset.EOF = False
strTest = Me.frmSubConduit.Form.Recordset.Fields("CircuitName").Value
If strCircuitName = strTest Then
dblAdd = Me.frmSubConduit.Form.Recordset.Fields("Area").Value
dblTotalArea = dblTotalArea + dblAdd
End If
Me.frmSubConduit.Form.Recordset.MoveNext
Loop

MyRS.CursorType = adOpenKeyset
MyRS.LockType = adLockOptimistic
MyRS.Open "tblCircuitArea", CurrentProject.Connection, , , adCmdTable

With MyRS
.AddNew
!CircuitName = strCircuitName
!TotalArea = dblTotalArea
.Update
End With
MyRS.Close

Me.frmUtility.Form.Recordset.MoveNext
blnTest = Me.frmUtility.Form.Recordset.EOF
Loop
 
Sorry, I found My Problem, and it involved properties on my form. These little revelations always make me feel brilliant.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top