cyberkey
Goto Top

Button im EndlosFormular Pro Zeile Automatisch betätigen

Wie das Thema schon lautet geht es um eine Code Optimierung =) bzw. Automatisierung.

Hallo,

Private Sub Ping_Click()
Dim strTarget, strPingResults, objShell, objExec
On Error Resume Next
strTarget = Me.IPall 'IP address or hostname  
Set objShell = CreateObject("WScript.Shell")  
Set objExec = objShell.Exec("ping -n 1 -w 10 " & strTarget)  
strPingResults = LCase(objExec.StdOut.ReadAll)
If InStr(strPingResults, "Antwort von") > 0 Then  
    'MsgBox ("Geht")  
    DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE Ip_adressen SET Status=1 WHERE IPall='" & strTarget & "'"  
    Me.Refresh
Else
    'MsgBox ("Geht nicht")  
    DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE Ip_adressen SET Status=0 WHERE IPall='" & strTarget & "'"  
    Me.Refresh
End If

End Sub


Dieser Code steht jetzt in Jeder Zeile eines Endlosformulares... als Button "Ping" mit einem Statusfeld. Kann man alle Knöpfe aus dem Formularkopf betätigen oder... das Script leicht optimierne damit alle Felder im Endlosformular... einen Status bekommen?


Habe sowas schonmal in Batch gesehen... Irgendwie .. eine Schleife : "For each item in ...." Do....

@zahlen=("Eins", "Zwei", "Drei", "Vier");  
foreach $i (@zahlen) {
	print "$i\n";  
}
[Leider Pearl] nicht VBA

[EDIT]
Private Sub Ping_akt_Click()
Dim lstElement
For Each lstElement In Me.IP_Adressen.IP_ID
   MsgBox " & lstElement & "  
Next
End Sub


Für Hilfe und Anregungen bin ich sehr Dankbar.
Gruß Cyberkey

Content-Key: 139470

Url: https://administrator.de/contentid/139470

Printed on: April 25, 2024 at 12:04 o'clock

Member: Cyberkey
Cyberkey Apr 01, 2010, updated at Oct 18, 2012 at 16:41:34 (UTC)
Goto Top