Hi.
Is it possible to get access to the wiresequence of a wiring diagram from VBA?
I'm looking for a more easy way to get the relationship between blocks than scanning through the wirenumbers in the TERMXX attributes.
It works, but it is very inefficient.
Colbjørn.
Solved! Go to Solution.
Solved by rhesusminus. Go to Solution.
Hi.
I got access to the database with the following code:
TBA. Got the code at home.
Colbjørn
Here is the code I use:
It's tested and it works, just remember to put the correct database location into the function before you use it.
Private Function ReadAccessDataBase(intReturn As Integer, strWIRENO As String, strCMP As String, strPIN As String) As String Dim oConn As ADODB.Connection Dim oRs As ADODB.Recordset Dim strConn As String Dim strSQL As String Dim strDBPath As String On Error GoTo ERRHANDLER: strDBPath = "location of scratch database" strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strDBPath & ";Persist Security Info=False;" Set oConn = New ADODB.Connection oConn.Open strConn strSQL = "SELECT * FROM WFRM2ALL WHERE (WIRENO = '" & strWIRENO & "') AND (NAM1 = '" & strCMP & "' OR NAM2 = '" & _ strCMP & "') AND (PIN1 = '" & strPIN & "' OR PIN2 = '" & strPIN & "')" Set oRs = New ADODB.Recordset oRs.Open strSQL, oConn, adOpenStatic, adLockReadOnly, adCmdText If oRs.Fields("NAM1") = strCMP And oRs.Fields("PIN1") = strPIN Then Select Case intReturn Case 0 ReadAccessDataBase = oRs.Fields("PIN2") GoTo JUMP Case 1 ReadAccessDataBase = oRs.Fields("NAM2") GoTo JUMP Case 2 ReadAccessDataBase = oRs.Fields("LOC2") GoTo JUMP Case 3 ReadAccessDataBase = oRs.Fields("INST2") GoTo JUMP End Select Else Select Case intReturn Case 0 ReadAccessDataBase = oRs.Fields("PIN1") GoTo JUMP Case 1 ReadAccessDataBase = oRs.Fields("NAM1") GoTo JUMP Case 2 ReadAccessDataBase = oRs.Fields("LOC1") GoTo JUMP Case 3 ReadAccessDataBase = oRs.Fields("INST1") GoTo JUMP End Select End If ReadAccessDataBase = "" JUMP: oRs.Close oConn.Close ERRHANDLER: Exit Function Resume End Function
Can't find what you're looking for? Ask the community or share your knowledge.