Code:
Option ExplicitPrivate Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Color1 As Variant
Public Color2 As Variant
Public Color3 As Variant
Public acad As Object
Public doc As Object
Public ms As Object
Public ss As Object
Public ssnew As Object
Public MsgBoxResp As Integer
Public Filter As String
Const pi = 3.14159
Function dtr(a As Double) As Double
dtr = (a / 180) * pi
End Function
Private Sub cmd_GEZNAME_Click()
TB_GEZNAME.SetFocus
Perso.Show
End Sub
Private Sub cmd_BAEDNAME1_Click()
TB_BAEDNAME1.SetFocus
Perso.Show
End Sub
Private Sub cmd_BAEDNAME2_Click()
TB_BAEDNAME2.SetFocus
Perso.Show
End Sub
Private Sub cmd_BAEDNAME3_Click()
TB_BAEDNAME3.SetFocus
Perso.Show
End Sub
Private Sub cmd_BAEDNAME4_Click()
TB_BAEDNAME4.SetFocus
Perso.Show
End Sub
Private Sub cmd_BAEDNAME5_Click()
TB_BAEDNAME5.SetFocus
Perso.Show
End Sub
Private Sub cmd_BAEDNAME6_Click()
TB_BAEDNAME6.SetFocus
Perso.Show
End Sub
Private Sub cmd_BAEDNAME7_Click()
TB_BAEDNAME7.SetFocus
Perso.Show
End Sub
Private Sub cmd_GEZDAM_Click()
TB_GEZDAM.SetFocus
Kalender01.Show
End Sub
Private Sub cmd_BAEDAM1_Click()
TB_BAEDAM1.SetFocus
Kalender01.Show
End Sub
Private Sub cmd_BAEDAM2_Click()
TB_BAEDAM2.SetFocus
Kalender01.Show
End Sub
Private Sub cmd_BAEDAM3_Click()
TB_BAEDAM3.SetFocus
Kalender01.Show
End Sub
Private Sub cmd_BAEDAM4_Click()
TB_BAEDAM4.SetFocus
Kalender01.Show
End Sub
Private Sub cmd_BAEDAM5_Click()
TB_BAEDAM5.SetFocus
Kalender01.Show
End Sub
Private Sub cmd_BAEDAM6_Click()
TB_BAEDAM6.SetFocus
Kalender01.Show
End Sub
Private Sub cmd_BAEDAM7_Click()
TB_BAEDAM7.SetFocus
Kalender01.Show
End Sub
Private Sub TB_Filter_Change()
TB_Filter.Text = Replace(TB_Filter.Text, "*", "&")
End Sub
Private Sub cmdSuchen_Click()
Filter = TB_Filter.Text
Filter = Replace(Filter, "*", "%")
If TB_Filter.Text = "" Then GoTo MyErrorHandler
Dim Cn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim LItem As ListItem
With Cn
.CursorLocation = adUseClient
'###--Hier die Datenbankverküpfung
End With
'.....
With ListView1
.ListItems.Clear
.ColumnHeaders.Clear
.View = lvwReport
.SmallIcons = ImageList1
.Sorted = True
End With
With ListView1.ColumnHeaders
.Add , , "Status", 13 'Status
.Add , , "Ba-Nr", 60 'Vorgangsnummer
.Add , , "Position", 40 'Auftragspositionsnummer
.Add , , "Objekt-Bezeichnung", 200 'Objektbezeichnung
.Add , , "Positions-Bezeichnung", 140 'Positionsbezeichnung
.Add , , "Projektleitung", 70 'Projektleitung
.Add , , "Montagebeginn", 60 'Montagebeginn
.Add , , "Vermerk", 60 'Vermerk
End With
'Rs.MoveFirst
Do Until Rs.EOF
Set LItem = ListView1.ListItems.Add()
LItem.Text = "" 'Status
LItem.SubItems(1) = (Rs!AUF_NR & "") 'Vorgangsnummer
LItem.SubItems(2) = (Rs!AUF_POS & "") 'Auftragspositionsnummer
LItem.SubItems(3) = (Rs!AUF_BEZEICHNUNG & "") 'Objektbezeichnung
LItem.SubItems(4) = (Rs!AUF_POS_BEZ & "") 'Positionsbezeichnung
LItem.SubItems(5) = (Rs!SACHBEARBEITER & "") 'Projektleitung
LItem.SubItems(6) = (Rs!AUF_MONTDATUM & "") 'Montagebeginn
LItem.SubItems(7) = (Rs!AUF_TERMIN_VERMERK & "") 'Vermerk
If Len(LItem.SubItems(7)) > 0 Then
LItem.SmallIcon = 1
End If
Rs.MoveNext
Loop
Rs.Close
Set Rs = Nothing
Cn.Close
Set Cn = Nothing
LB_LV_Anzahl.Caption = "Anzahl der gefundenen Datensätze = " & ListView1.ListItems.Count
Exit Sub
MyErrorHandler:
MsgBox "Es wurde kein Suchkreterium eingegeben", 64, "Hinweis"
End Sub
Private Sub cmdUebergabe_Click()
UpdateAttrib 0, StartMask.TB_BBVH1.Text
UpdateAttrib 1, StartMask.TB_BBVH2.Text
UpdateAttrib 2, StartMask.TB_GEZDAM.Text
UpdateAttrib 3, StartMask.TB_GEZNAME.Text
UpdateAttrib 4, StartMask.TB_BBESCHREIB.Text
UpdateAttrib 5, StartMask.TB_BBESCHREIB1.Text
UpdateAttrib 6, StartMask.TB_BBESCHREIB2.Text
UpdateAttrib 7, StartMask.TB_BBESCHREIB3.Text
UpdateAttrib 8, StartMask.TB_BAUFTRAG.Text
UpdateAttrib 9, StartMask.TB_BLATT.Text
UpdateAttrib 10, StartMask.TB_BAEDAM1.Text
UpdateAttrib 11, StartMask.TB_BAEDNAME1.Text
UpdateAttrib 12, StartMask.TB_BAEDAM2.Text
UpdateAttrib 13, StartMask.TB_BAEDNAME2.Text
UpdateAttrib 14, StartMask.TB_BAEDAM3.Text
UpdateAttrib 15, StartMask.TB_BAEDNAME3.Text
UpdateAttrib 16, StartMask.TB_BAEDAM4.Text
UpdateAttrib 17, StartMask.TB_BAEDNAME4.Text
UpdateAttrib 18, StartMask.TB_BAEDAM5.Text
UpdateAttrib 19, StartMask.TB_BAEDNAME5.Text
UpdateAttrib 20, StartMask.TB_BAEDAM6.Text
UpdateAttrib 21, StartMask.TB_BAEDNAME6.Text
UpdateAttrib 22, StartMask.TB_BAEDAM7.Text
UpdateAttrib 23, StartMask.TB_BAEDNAME7.Text
UpdateAttrib 24, StartMask.TB_LYBEZEICH.Text
UpdateAttrib 25, StartMask.TB_BETAUFTRAG.Text
UpdateAttrib 26, StartMask.TB_BETAUFTRAG1.Text
Unload Me
End
End Sub
Sub UpdateAttrib(TagNumber As Integer, BTextString As String)
'--Attributswert auf Nullwert prüfen--!!!
If BTextString = "" Then
AttWert(TagNumber).TextString = "-"
Else
AttWert(TagNumber).TextString = BTextString
End If
End Sub
Public Sub UserForm_Initialize()
On Error Resume Next
Me.Hide
StartMask.TB_BBVH1.Text = Strings.LTrim(AttWert(0).TextString)
StartMask.TB_BBVH2.Text = Strings.LTrim(AttWert(1).TextString)
StartMask.TB_GEZDAM.Text = Strings.LTrim(AttWert(2).TextString)
StartMask.TB_GEZNAME.Text = Strings.LTrim(AttWert(3).TextString)
StartMask.TB_BBESCHREIB.Text = Strings.LTrim(AttWert(4).TextString)
StartMask.TB_BBESCHREIB1.Text = Strings.LTrim(AttWert(5).TextString)
StartMask.TB_BBESCHREIB2.Text = Strings.LTrim(AttWert(6).TextString)
StartMask.TB_BBESCHREIB3.Text = Strings.LTrim(AttWert(7).TextString)
StartMask.TB_BAUFTRAG.Text = Strings.LTrim(AttWert(8).TextString)
StartMask.TB_BLATT.Text = Strings.LTrim(AttWert(9).TextString)
StartMask.TB_BAEDAM1.Text = Strings.LTrim(AttWert(10).TextString)
StartMask.TB_BAEDNAME1.Text = Strings.LTrim(AttWert(11).TextString)
StartMask.TB_BAEDAM2.Text = Strings.LTrim(AttWert(12).TextString)
StartMask.TB_BAEDNAME2.Text = Strings.LTrim(AttWert(13).TextString)
StartMask.TB_BAEDAM3.Text = Strings.LTrim(AttWert(14).TextString)
StartMask.TB_BAEDNAME3.Text = Strings.LTrim(AttWert(15).TextString)
StartMask.TB_BAEDAM4.Text = Strings.LTrim(AttWert(16).TextString)
StartMask.TB_BAEDNAME4.Text = Strings.LTrim(AttWert(17).TextString)
StartMask.TB_BAEDAM5.Text = Strings.LTrim(AttWert(18).TextString)
StartMask.TB_BAEDNAME5.Text = Strings.LTrim(AttWert(19).TextString)
StartMask.TB_BAEDAM6.Text = Strings.LTrim(AttWert(20).TextString)
StartMask.TB_BAEDNAME6.Text = Strings.LTrim(AttWert(21).TextString)
StartMask.TB_BAEDAM7.Text = Strings.LTrim(AttWert(22).TextString)
StartMask.TB_BAEDNAME7.Text = Strings.LTrim(AttWert(23).TextString)
StartMask.TB_LYBEZEICH.Text = Strings.LTrim(AttWert(24).TextString)
StartMask.TB_BETAUFTRAG.Text = Strings.LTrim(AttWert(25).TextString)
StartMask.TB_BETAUFTRAG1.Text = Strings.LTrim(AttWert(26).TextString)
Call ButtonUser(cmd_GEZNAME)
Call ButtonUser(cmd_BAEDNAME1)
Call ButtonUser(cmd_BAEDNAME2)
Call ButtonUser(cmd_BAEDNAME3)
Call ButtonUser(cmd_BAEDNAME4)
Call ButtonUser(cmd_BAEDNAME5)
Call ButtonUser(cmd_BAEDNAME6)
Call ButtonUser(cmd_BAEDNAME7)
Call ButtonDate(cmd_GEZDAM)
Call ButtonDate(cmd_BAEDAM1)
Call ButtonDate(cmd_BAEDAM2)
Call ButtonDate(cmd_BAEDAM3)
Call ButtonDate(cmd_BAEDAM4)
Call ButtonDate(cmd_BAEDAM5)
Call ButtonDate(cmd_BAEDAM6)
Call ButtonDate(cmd_BAEDAM7)
Call TBNOTCHANGE(TB_Z_NAME)
Call TBNOTCHANGE(TB_BAUFTRAG)
Call TBNOTCHANGE(TB_BETAUFTRAG)
Call TBNOTCHANGE(TB_BETAUFTRAG1)
Call TBNOTCHANGE(TB_BLATT)
Call TBNOTCHANGE(TB_LYBEZEICH)
Call TBNOTCHANGE(TB_BBVH1)
Color1 = RGB(241, 201, 70) 'gelb/grün
Color2 = RGB(255, 31, 31) 'rot
Color3 = RGB(112, 112, 112) 'grau
ComboBox1.Clear
With ListView1
.ListItems.Clear
.ColumnHeaders.Clear
.View = lvwReport
End With
With ListView1.ColumnHeaders
.Add , , "Status", 13 'Status
.Add , , "Ba-Nr", 60 'Vorgangsnummer
.Add , , "Position", 40 'Auftragspositionsnummer
.Add , , "Objekt-Bezeichnung", 200 'Objektbezeichnung
.Add , , "Positions-Bezeichnung", 140 'Positionsbezeichnung
.Add , , "Projektleitung", 70 'Projektleitung
.Add , , "Montagebeginn", 60 'Montagebeginn
.Add , , "Vermerk", 60 'Vermerk
End With
Dim a(3) As String
Dim I As Integer
a(1) = ListView1.ColumnHeaders(2)
a(2) = ListView1.ColumnHeaders(4)
a(3) = ListView1.ColumnHeaders(5)
For I = 1 To UBound(a)
ComboBox1.AddItem a(I)
Next I
ComboBox1.Text = ComboBox1.List(0)
Dim n As String
Dim ALayout As AcadLayout
Set ALayout = ThisDrawing.ActiveLayout
n = ThisDrawing.Layouts.Count - 1
TB_BLATT.Text = ALayout.TabOrder & " / " & n
TB_LYBEZEICH.Text = ThisDrawing.ActiveLayout.Name
With TB_Filter
.Locked = False
End With
With cmdEnde
.Caption = "Abbrechen / Beenden"
.Picture = ImageList1.ListImages(2).Picture
.PicturePosition = fmPicturePositionLeftCenter
End With
With cmdInfo
.Caption = ""
.Picture = ImageList1.ListImages(4).Picture
.PicturePosition = fmPicturePositionCenter
End With
With cmdSuchen
.Caption = ""
.Picture = ImageList1.ListImages(16).Picture
.PicturePosition = fmPicturePositionLeftCenter
End With
'With cmdVerzeichnis
' .Picture = ImageList1.ListImages(3).Picture
' .PicturePosition = fmPicturePositionCenter
'End With
With cmdOptionen
.Caption = ""
.Picture = ImageList1.ListImages(3).Picture
.PicturePosition = fmPicturePositionLeftCenter
.Visible = False
End With
With cmdUebergabe
.Caption = " Erfassungen abspeichern"
.Picture = ImageList1.ListImages(1).Picture
.PicturePosition = fmPicturePositionLeftCenter
.BackColor = Color1
End With
With cmdUmschalt
.Caption = ""
.Picture = ImageList1.ListImages(13).Picture
.PicturePosition = fmPicturePositionLeftCenter
End With
With ImageBorm
.Picture = ImageList1.ListImages(15).Picture
.PictureAlignment = fmPictureAlignmentCenter
.PictureSizeMode = fmPictureSizeModeZoom
.BackColor = StartMask.BackColor
.BorderStyle = fmBorderStyleNone
End With
With cmdDBConect
.Caption = ""
.Picture = ImageList1.ListImages(15).Picture
.PicturePosition = fmPicturePositionLeftCenter
End With
StatusBar1.Panels(1).Text = VBE.activevbproject.FileName
'--Anzahl dergefundenen Datensätze anzeigen
LB_LV_Anzahl.Caption = ""
'--Datenbankpfad für den Registryeintrag festlegen
Dim regpfad As String
Dim Wert As String
regpfad = "HKEY_CURRENT_USER\Software\Autodesk\DB_Tuning\BlockV3\DB_Pfad"
' StartMask.TextBox1.Text = RegRead(regpfad)
'--MyErrorHandler--!!! '????noch nicht definiert????
'Exit Sub
'MyErrorHandler1:
' MsgBox "Dieses Tool ist nur im Layout - Papierbereich einsetzbar.", 64, "Hinweis"
'MyErrorHandler2:
' MsgBox "Es ist kein Schriftfeldblock vorhanden.", 64, "Hinweis"
End Sub