Here's the second. The code was too long so I had to eliminate some of it - I believe it demonstates what's happening.
Code:Private Sub UpdateSanMan() Dim sUpdate As String sUpdate = "update SAN_MH set Label =" If Not Trim(txtLabel.Text) = "" Then sUpdate = sUpdate + """" + Trim(txtLabel.Text) + """" Else sUpdate = sUpdate + "NULL" End If sUpdate = sUpdate + ", Rim_Elev=" If Not Trim(txtRim_Elev.Text) = "" Then sUpdate = sUpdate + """" + Trim(txtRim_Elev.Text) + """" Else sUpdate = sUpdate + "NULL" End If sUpdate = sUpdate + ", Const_Date=" If Not Trim(txtConst_Date.Text) = "" Then sUpdate = sUpdate + """" + Trim([txtConst_Date].Text) + """" Else sUpdate = sUpdate + "NULL" End If sUpdate = sUpdate + ", Orig_Date=" If Not Trim(txtOrig_Date.Text) = "" Then sUpdate = sUpdate + """" + Trim([txtOrig_Date].Text) + """" Else sUpdate = sUpdate + "NULL" End If sUpdate = sUpdate + ", ABAN_Date=" If Not Trim(txtAban_Date.Text) = "" Then sUpdate = sUpdate + """" + Trim([txtAban_Date].Text) + """" Else sUpdate = sUpdate + "NULL" End If sUpdate = sUpdate + ", [Sect_NO]=" If Not Trim(txtSect_NO.Text) = "" Then sUpdate = sUpdate + """" + Trim([txtSect_NO].Text) + """" Else sUpdate = sUpdate + "NULL" End If sUpdate = sUpdate + ", Plat=" If Not Trim(txtPlat.Text) = "" Then sUpdate = sUpdate + """" + Trim([txtPlat].Text) + """" Else sUpdate = sUpdate + "NULL" End If sUpdate = sUpdate + ", Owner=" If Not Trim(cboOwner.Text) = "" Then sUpdate = sUpdate + """" + Trim([cboOwner].Text) + """" Else sUpdate = sUpdate + "NULL" End If sUpdate = sUpdate + ", Inflow_1=" If Not Trim(txtInflow_1.Text) = "" Then sUpdate = sUpdate + """" + Trim([txtInflow_1].Text) + """" Else sUpdate = sUpdate + "NULL" End If sUpdate = sUpdate + ", Inflow_4=" If Not Trim(txtInflow_4.Text) = "" Then sUpdate = sUpdate + """" + Trim([txtInflow_4].Text) + """" Else sUpdate = sUpdate + "NULL" End If sUpdate = sUpdate + ", INFL_INV5=" If Not Trim(txtINFL_INV5.Text) = "" Then sUpdate = sUpdate + """" + Trim([txtINFL_INV5].Text) + """" Else sUpdate = sUpdate + "NULL" End If sUpdate = sUpdate + ", INFL_DIR5=" If Not Trim(txtINFL_DIR5.Text) = "" Then sUpdate = sUpdate + """" + Trim([txtINFL_DIR5].Text) + """" Else sUpdate = sUpdate + "NULL" End If sUpdate = sUpdate + " where MSLink = " + lblMSLinkID.Caption Set obj1 = New Class1 obj1.dynExecute = sUpdate Set obj1 = Nothing 'Here I need to loop through all connected pipes and assign the label and things like that Dim oenumerator As ElementEnumerator Dim ele As Element Set oenumerator = ActiveModelReference.GetSelectedElements Dim EleCount As Integer Dim CellElement As CellElement EleCount = 0 Do While oenumerator.MoveNext Set ele = oenumerator.Current If ele.IsCellElement Then Set CellElement = ele End If Loop CellOrigin = CellElement.Origin Dim USlabel As String Dim DSlabel(2) As String Dim USMSLINKID As String Dim DSMslinkID(2) As String Dim CurrentOUTPipeMSLINKID(2) As String Dim CurrentINPipeMSLINKID(5) As String Set obj1 = New Class1 'FIRST THE OUTFLOWS.... If Trim(txtOutflow_1.Text) <> "" And Trim(txtOutflow_1.Text) <> "0" Then obj1.dynExecute = "UPDATE SAN_PIPE SET US_LABEL = '" & txtLabel.Text & "', US_MANHOLE = '" & lblMSLinkID.Caption & "' " & _ " Where((mslink) = " & Trim(txtOutflow_1.Text) & ")" End If If Trim(txtOutflow_2.Text) <> "" And Trim(txtOutflow_2.Text) <> "0" Then obj1.dynExecute = "UPDATE SAN_PIPE SET US_LABEL = '" & txtLabel.Text & "', US_MANHOLE = '" & lblMSLinkID.Caption & "' " & _ " Where((mslink) = " & Trim(txtOutflow_2.Text) & ")" End If 'Now the INFLOWS.... If Trim(txtInflow_1.Text) <> "" And Trim(txtInflow_1.Text) <> "0" Then obj1.dynExecute = "UPDATE SAN_PIPE SET DS_LABEL = '" & txtLabel.Text & "', DS_MANHOLE = '" & lblMSLinkID.Caption & "' " & _ " Where((mslink) = " & Trim(txtInflow_1.Text) & ")" End If If Trim(txtInflow_2.Text) <> "" And Trim(txtInflow_2.Text) <> "0" Then obj1.dynExecute = "UPDATE SAN_PIPE SET DS_LABEL = '" & txtLabel.Text & "', DS_MANHOLE = '" & lblMSLinkID.Caption & "' " & _ " Where((mslink) = " & Trim(txtInflow_2.Text) & ")" End If If Trim(txtInflow_3.Text) <> "" And Trim(txtInflow_3.Text) <> "0" Then obj1.dynExecute = "UPDATE SAN_PIPE SET DS_LABEL = '" & txtLabel.Text & "', DS_MANHOLE = '" & lblMSLinkID.Caption & "' " & _ " Where((mslink) = " & Trim(txtInflow_3.Text) & ")" End If If Trim(txtInflow_4.Text) <> "" And Trim(txtInflow_4.Text) <> "0" Then obj1.dynExecute = "UPDATE SAN_PIPE SET DS_LABEL = '" & txtLabel.Text & "', DS_MANHOLE = '" & lblMSLinkID.Caption & "' " & _ " Where((mslink) = " & Trim(txtInflow_4.Text) & ")" End If If Trim(txtInflow_5.Text) <> "" And Trim(txtInflow_5.Text) <> "0" Then obj1.dynExecute = "UPDATE SAN_PIPE SET DS_LABEL = '" & txtLabel.Text & "', DS_MANHOLE = '" & lblMSLinkID.Caption & "' " & _ " Where((mslink) = " & Trim(txtInflow_5.Text) & ")" End If Set obj1 = Nothing glbResponse = 1 End Sub




Reply With Quote