Neuigkeiten:

Wenn ihr euch für eine gute Antwort bedanken möchtet, im entsprechenden Posting einfach den Knopf "sag Danke" drücken!

Mobiles Hauptmenü

Function die Feld überprüft

Begonnen von peX, September 09, 2016, 10:02:42

⏪ vorheriges - nächstes ⏩

peX

Hallo Accessler,

ich habe ein Formular in dem zwei Felder sind in denen jeweils ein Datum eintragen werden muss (von - bis). In meiner DB sind viele Abfragen enthalten die genau diese Infos benötigen und ich rufe jedesmal die komplette Überprüfung ob die Felder gefüllt sind auf (s.u.).

Ich würde gerne immer nur eine Funktion aufrufen, allerdings weiß ich nicht wie und wo ich das einbinden muss. Könnt Ihr mit da weiterhelfen?


Private Sub Reprot1_Click()
If Nz(Forms!Navigation!Datum_von) = 0 And Nz(Forms!Navigation!Datum_bis) = 0 Then
    MsgBox "Datum von und Datum bis fehlt"
    Forms!Navigation!Datum_von.SetFocus
ElseIf Nz(Forms!Navigation!Datum_von) = 0 Then
    MsgBox "Datum von fehlt"
    Forms!Navigation!Datum_von.SetFocus
ElseIf Nz(Forms!Navigation!Datum_bis) = 0 Then
    MsgBox "Datum bis fehlt"
    Forms!Navigation!Datum_bis.SetFocus
Else
    Call SQL_Report1
End If
End Sub


Danke und Grüße
peX

DF6GL

Hallo,


etwa so:

in einem Standardmodul:

Option Compare Database
Option Explicit

Public Function fktCheckDates()    Sub Reprot1_Click()
If Nz(Forms!Navigation!Datum_von,0) = 0 And Nz(Forms!Navigation!Datum_bis,0) = 0 Then
    MsgBox "Datum von und Datum bis fehlt"
    Forms!Navigation!Datum_von.SetFocus
ElseIf Nz(Forms!Navigation!Datum_von,0) = 0 Then
    MsgBox "Datum von fehlt"
    Forms!Navigation!Datum_von.SetFocus
ElseIf Nz(Forms!Navigation!Datum_bis,0) = 0 Then
    MsgBox "Datum bis fehlt"
    Forms!Navigation!Datum_bis.SetFocus
Else
    Call SQL_Report1
End If
End Function


in der/den Ereignisprozedur/en:

Private Sub Reprot1_Click()
fktCheckDates
End Sub


Die Prozedur "SQL_Report1"  muss sich auch in einem Standardmodul als Public deklariert befinden.
Viele Grüße vom Bodensee
Franz, DF6GL

Hilfestellung:  http://www.access-o-mania.de/forum/index.php?topic=6969.msg118738#msg118738

Links und Tipps:
1.   http://v.hdm-stuttgart.de/~riekert/lehre/db-kelz/
1a. http://www.tinohempel.de/info/info/datenbank/normalisierung.htm
1b. https://support.office.com/de-de/article/Grundlagen-des-Datenbankentwurfs-eb2159cf-1e30-401a-8084-bd4f9c9ca1f5#bmterms
2.   http://www.donkarl.com
3.   https://web.archive.org/web/20201201233522/http://www.dbwiki.net/
4.   http://www.access-tutorial.de/
5.   http://www.tty1.net/smart-questions_de.htm
6.   http://access.joposol.com/accept

Last but not least:   < F1 > für Hilfe
;) Learning by doing not by spoon-feed ;)

Tipp: Find and Replace for Access