Access-o-Mania

Access-Forum (Deutsch/German) => Access-Hilfe => Thema gestartet von: Ratoncito am Februar 23, 2020, 09:17:05

Titel: Access beeinflusst Datei-Explorer
Beitrag von: Ratoncito am Februar 23, 2020, 09:17:05
Hallo,

zum Eintragen von Daten habe ich Access, den Rechner und 2 mal den Windows Datei Explorer mit unterschiedlichen PDF-Dateien geöffnet.
Nach dem Ausfüllen des letzten Feldes erfolgt eine Abfrage (MsgBox) ob alle Daten korrekt sind und die Daten gespeichert werden sollen.
Hierbei wird regelmäßig das Vorschaufenster des Datei-Explorers mit dem Inhalt des anderen Fensters überschrieben.

Hat jemand eine Idee was es damit auf sich hat, und wie man das verhindern kann?

LG - Wolfgang
Titel: Re: Access beeinflusst Datei-Explorer
Beitrag von: DF6GL am Februar 23, 2020, 13:43:17
Hallo,

vermutlich wird die angezeigte Datei geändert und der Explorer zeigt sie dann aktualisiert an.

ZitatNach dem Ausfüllen des letzten Feldes erfolgt eine Abfrage (MsgBox) ob alle Daten korrekt sind und die Daten gespeichert werden sollen

Zeig mal den Code, der dieses bewerkstelligt..
Titel: Re: Access beeinflusst Datei-Explorer
Beitrag von: Ratoncito am Februar 23, 2020, 16:09:33
Hallo,

vor Jahren bin ich mal auf die MSG-Box gestoßen und habe sie verwendet. 


Option Compare Database
Option Explicit

Private Const conLeftBorder As Long = 150, conTopBorder As Long = 200
Private Const conImageWidthHeight As Long = 567
Private Const conButtonSpaceBetween As Long = 100, conButtonSpaceLeftRight As Long = 500
Private Const conButtonSizeMin As Long = 1500, conButtonHeight As Long = 350
Private Const conLongButtonLenTrigger As Long = 15

Dim lngButtonClicked As Long
Dim bolAnyImage As Boolean
Dim lngButtonCount As Long, lngDefaultButton As Long
Dim arrButtonText(1 To 6) As String
Dim bolLongButtons As Boolean


Property Get propButtonClicked() As Long
  propButtonClicked = lngButtonClicked
End Property

Property Let propVbImage(lng As Long)
  Select Case lng
    Case vbInformation: Me.img_vbInformation.Visible = True
    Case vbQuestion: Me.img_vbQuestion.Visible = True
    Case vbExclamation: Me.img_vbExclamation.Visible = True
    Case vbCritical: Me.img_vbCritical.Visible = True
  End Select
  If lng > 0 Then bolAnyImage = True
End Property

Property Let propTitle(str As String)
  If str = " " Then str = "Message..."
  If str = "" Then str = " "
  Me.Caption = str
End Property
Property Let propMsgText(str As String)
  Me.labMsgText.Caption = str
End Property

Property Let propButton(lng As Long, str As String)
  lngButtonCount = fbasMsgBox2Max(lngButtonCount, lng)
  arrButtonText(lng) = str
End Property
Property Let propDefaultButton(lng As Long)
  Select Case lng
    Case 0: lngDefaultButton = 1
    Case 256: lngDefaultButton = 2
    Case 512: lngDefaultButton = 3
    Case 768: lngDefaultButton = 4
    Case 1024: lngDefaultButton = 5
    Case 1280: lngDefaultButton = 6
  End Select
End Property

Property Let propLongButtons(bol As Boolean)
  bolLongButtons = bol
End Property

Public Sub Init()
Dim lngLineCount As Long, lngMaxLineLen As Long
Dim lngMsgWidth As Long, lngMsgHeight As Long
Dim lngWindowWidth As Long, lngWindowHeight As Long
Dim lng As Long
Dim lngButtonWidth As Long, lngButtonWidthComplete As Long
Dim lngMaxButtonTextLen As Long, lngButtonLeftStartPos As Long

  ' Textbox Größe ermitteln
  pfbasCalcTextSize Me.labMsgText.Caption, lngLineCount, lngMaxLineLen

  ' evtl. lange Knöpfe verwenden
  lngMaxButtonTextLen = 0
  For lng = 1 To 6
    'If Len(arrButtonText(lng)) > conLongButtonLenTrigger Then bolLongButtons = True
    If Len(arrButtonText(lng)) + 10 > lngMaxLineLen Then lngMaxLineLen = Len(arrButtonText(lng)) + 10
    If Len(arrButtonText(lng)) > lngMaxButtonTextLen Then lngMaxButtonTextLen = Len(arrButtonText(lng))
  Next

  ' Textbox Breite/Höhe ausrechnen
  lngMsgHeight = lngLineCount * 210
    If lngMsgHeight < 800 Then lngMsgHeight = 800
    lngMsgHeight = lngMsgHeight + 200
  lngMsgWidth = lngMaxLineLen * 85
    If lngMsgWidth < 1000 Then lngMsgHeight = 1000

  ' linker und rechter Rand
  lngWindowWidth = conLeftBorder * 2
  ' evtl. Bild und Zwischenraum dazu
  If bolAnyImage Then lngWindowWidth = lngWindowWidth + (conLeftBorder + conImageWidthHeight)
  ' Breite der Msg dazu
  lngWindowWidth = lngWindowWidth + lngMsgWidth
  ' evtl. wegen vielen Knöpfen die Breite erweitern
  If Not bolLongButtons Then lngWindowWidth = fbasMsgBox2Max(lngWindowWidth, (lngButtonCount * conButtonSizeMin) + ((lngButtonCount - 1) * conButtonSpaceBetween) + (2 * conButtonSpaceLeftRight))
 
  ' Testen, ob die Knöpfe horizontal passen, wenn nicht auf Vertikale Anordnung umschalten
  lngButtonWidth = (lngMaxButtonTextLen * 90) + 1000
  lngButtonWidthComplete = (lngButtonWidth * lngButtonCount) + (conButtonSpaceBetween * (lngButtonCount - 1))
  If lngButtonWidthComplete + (2 * conButtonSpaceLeftRight) > 15000 Then
    If lngButtonWidthComplete + (2 * conButtonSpaceLeftRight) > lngWindowWidth Then bolLongButtons = True
  End If
 
  ' evtl. wegen vielen Knöpfen die Breite erweitern
  If Not bolLongButtons Then lngWindowWidth = fbasMsgBox2Max(lngWindowWidth, (lngButtonCount * conButtonSizeMin) + ((lngButtonCount - 1) * conButtonSpaceBetween) + (2 * conButtonSpaceLeftRight))
 
  ' oberer und unterer Rand
  lngWindowHeight = conTopBorder + (conButtonSpaceBetween * 2)
  ' Nachrichtenhöhe
  lngWindowHeight = lngWindowHeight + lngMsgHeight
  ' Knopfhöhe
  If bolLongButtons Then
    lngWindowHeight = lngWindowHeight + (lngButtonCount * conButtonHeight) + ((lngButtonCount - 1) * conButtonSpaceBetween)
  Else
    lngWindowHeight = lngWindowHeight + conButtonHeight
  End If

  ' Fenstergröße anpassen
  Me.Width = lngWindowWidth: Me.InsideWidth = lngWindowWidth
  Me.InsideHeight = lngWindowHeight: Me.Detailbereich.Height = lngWindowHeight
 
 
  ' Steuerelemente plazieren
  ' bilder
  Me.img_vbCritical.Left = conLeftBorder: Me.img_vbCritical.Top = conTopBorder: Me.img_vbCritical.Width = conImageWidthHeight: Me.img_vbCritical.Height = conImageWidthHeight
  Me.img_vbExclamation.Left = conLeftBorder: Me.img_vbExclamation.Top = conTopBorder: Me.img_vbExclamation.Width = conImageWidthHeight: Me.img_vbExclamation.Height = conImageWidthHeight
  Me.img_vbInformation.Left = conLeftBorder: Me.img_vbInformation.Top = conTopBorder: Me.img_vbInformation.Width = conImageWidthHeight: Me.img_vbInformation.Height = conImageWidthHeight
  Me.img_vbQuestion.Left = conLeftBorder: Me.img_vbQuestion.Top = conTopBorder: Me.img_vbQuestion.Width = conImageWidthHeight: Me.img_vbQuestion.Height = conImageWidthHeight
  ' Textbox
  Me.labMsgText.Left = conLeftBorder + IIf(bolAnyImage, conLeftBorder + conImageWidthHeight, 0): Me.labMsgText.Top = conTopBorder
  Me.labMsgText.Width = lngMsgWidth: Me.labMsgText.Height = lngMsgHeight
  ' Knöpfe
  If bolLongButtons Then
    lngButtonWidth = lngWindowWidth - (2 * conButtonSpaceLeftRight)
    For lng = 1 To lngButtonCount
      With Me.Controls("but" & Trim(CStr(lng)))
        .Visible = True
        .Caption = arrButtonText(lng)
        .Left = conButtonSpaceLeftRight
        .Width = lngButtonWidth
        .Top = conTopBorder + lngMsgHeight + conButtonSpaceBetween + ((lng - 1) * (conButtonHeight + conButtonSpaceBetween))
        .Height = conButtonHeight
      End With
    Next
  Else
    ' Knopfgröße bei optimaler Verteilung ermitteln
    lngButtonWidth = lngWindowWidth - (2 * conButtonSpaceLeftRight)
    lngButtonWidth = lngButtonWidth - ((lngButtonCount - 1) * conButtonSpaceBetween)
    lngButtonWidth = lngButtonWidth \ lngButtonCount
    ' evtl. Knöpfe verkleinern wenn wenig Text drinnen ist
    If lngButtonWidth > (lngMaxButtonTextLen * 90) + 1000 Then lngButtonWidth = (lngMaxButtonTextLen * 90) + 1000
    ' Linke Startposition für die Knöpfe ermitteln
    lngButtonLeftStartPos = (lngWindowWidth - ((lngButtonWidth * lngButtonCount) + (conButtonSpaceBetween * (lngButtonCount - 1)))) \ 2
    ' Knöpfe positionieren
    For lng = 1 To lngButtonCount
      With Me.Controls("but" & Trim(CStr(lng)))
        .Visible = True
        .Caption = arrButtonText(lng)
        .Left = lngButtonLeftStartPos + ((lng - 1) * (lngButtonWidth + conButtonSpaceBetween))
        .Width = lngButtonWidth
        .Top = conTopBorder + lngMsgHeight + conButtonSpaceBetween
        .Height = conButtonHeight
      End With
    Next
  End If

  Me.Visible = True
  Me.Controls("but" & Trim(CStr(lngDefaultButton))).SetFocus

End Sub

Private Sub pfbasCalcTextSize(str As String, ByRef reslngLineCount As Long, ByRef reslngMaxLineLen As Long)
Dim lngLineLen As Long
Dim lngPos As Long
Dim lngChar As Long

  reslngLineCount = 1
  reslngMaxLineLen = 0
  For lngPos = 1 To Len(str)
    lngChar = Asc(Mid(str, lngPos, 1))
    If lngChar = 10 Then
      lngLineLen = 0
      reslngLineCount = reslngLineCount + 1
    ElseIf lngChar = 13 Then
      lngLineLen = 0
    Else
      lngLineLen = lngLineLen + 1
      If lngLineLen > reslngMaxLineLen Then reslngMaxLineLen = lngLineLen
    End If
  Next

End Sub

Private Sub but1_Click()
  lngButtonClicked = vbButton1
  Me.Visible = False
End Sub
Private Sub but2_Click()
  lngButtonClicked = vbButton2
  Me.Visible = False
End Sub
Private Sub but3_Click()
  lngButtonClicked = vbButton3
  Me.Visible = False
End Sub
Private Sub but4_Click()
  lngButtonClicked = vbButton4
  Me.Visible = False
End Sub
Private Sub but5_Click()
  lngButtonClicked = vbButton5
  Me.Visible = False
End Sub
Private Sub but6_Click()
  lngButtonClicked = vbButton6
  Me.Visible = False
End Sub

Private Sub Form_Load()
  lngButtonCount = 0
  bolLongButtons = False
  Me.Caption = "Message..."
End Sub



Bisher gab es keine Probleme. Allerdings hatte ich bis dahin auch nicht so viele Fenster geöffnet. Mir ist noch aufgefallen, dass die Taskleiste manchmal einfriert und das Programm "Rechner" sich nicht schließen lässt. Eventuell ist es auch ein Problem mit Windows.

LG - Wolfgang
Titel: Re: Access beeinflusst Datei-Explorer
Beitrag von: DF6GL am Februar 23, 2020, 17:22:07
Hallo,

sehe da auch keinen Code-Schnipsel, der sich auf die Anzeige im Explorer beziehen könnte..

Titel: Re: Access beeinflusst Datei-Explorer
Beitrag von: Hondo am Februar 23, 2020, 19:08:02
Und was steckt hinter der Prozedur fbasMsgBox2Max()?
Titel: Re: Access beeinflusst Datei-Explorer
Beitrag von: Hondo am Februar 23, 2020, 19:22:03
Dein Code stammt wohl von TommyK, siehe auch hier:  https://www.tksoft-online.de/ms-access/bsp-db-s/bsp-downloads-sonstiges/67-ersatz-fuer-die-standard-messagebox-mit-benutzerdefinierten-buttonbschriftungen.html (https://www.tksoft-online.de/ms-access/bsp-db-s/bsp-downloads-sonstiges/67-ersatz-fuer-die-standard-messagebox-mit-benutzerdefinierten-buttonbschriftungen.html)
Ich kann aber beim besten Willen keine Beeinflussung des Windows Explorer erkennen.
Gruß Andreas
Titel: Re: Access beeinflusst Datei-Explorer
Beitrag von: Ratoncito am Februar 23, 2020, 21:19:30
Hallo,

vielen Dank für Eure Hilfe.

@Andreas
Die Seite war es nicht, könnte aber von Access Guru sein, die Seite wird in dem Beitrag erwähnt.

Zitat von: Hondo am Februar 23, 2020, 19:08:02
Und was steckt hinter der Prozedur fbasMsgBox2Max()?

Die Frage verstehe ich nicht.

Obwohl das Überschreiben der Datei im Vorschaufenster des Explorers beim Aufruf der MSG-Box erfolgt, vermute ich im Moment eher ein Problem am Betriebssystem.

Sobald ich mehr weiss, melde ich mich.

Danke, und noch einen schönen Abend - Wolfgang
Titel: Re: Access beeinflusst Datei-Explorer
Beitrag von: Ratoncito am Februar 27, 2020, 10:47:47
Hallo,

kurzes Update. Betriebssystem sollte okay sein. Probleme gibt es nur wenn 2 Explorerfenster geöffnet sind.

Wenn jemand noch eine Idee hat...

LG - Wolfgang