Toon posts:

[VBA/ACCESS] controle op formulier

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik wil dus dat er vooralleer er een nieuwe recordset wordt toegevoegd dat er wordt gecontrolleerd dat alle velden in het formulier zijn ingevuld. Nu heb ik al geprobeert met Me!objectnaam en met objectnaam.value.. en geen van beide blijkt invloed te hebben.. de recordset wordt zoiezo toegevoegd al dan niet of alles is ingevuld.

hier is de code:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Private Sub cmdInvoeren_Click()

Dim rstKlant As New ADODB.Recordset

With rstKlant
    .ActiveConnection = CurrentProject.Connection
    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
    .Open "tblKlanten"
    
    
    If txtNaam.Value = Null Or txtVoornaam.Value = Null Or txtAdres.Value = Null Or txtNr.Value = Null _
    Or txtPostcode.Value = Null Or txtGemeente.Value = Null Or txtTelefoonnr.Value = Null _
    Or dteGeboortedatum.Value = Null Or cboGeslacht.Value = Null Then
            MsgBox "Gelieve alle gegevens in te vullen"
    Else
        .AddNew
        !Naam = Me!txtNaam
        !Voornaam = Me!txtVoornaam
        !Adres = Me!txtAdres & " " & Me!txtNr
        !Postcode = Me!txtPostcode
        !Gemeente = Me!txtGemeente
        !Telefoon = Me!txtTelefoonnr
        !Geboortedatum = Me!dteGeboortedatum
        !Geslacht = Me!cboGeslacht
        .Update
        MsgBox "Nieuwe Klant is toegevoegd", vbOKOnly
    End If
End With

    
End Sub


ik heb ook al geprobeerd om per object een controle tedoen zodat je dan specifieke details kreeg van wat al dan niet ingevuld was.. maar ook hier werkte de controle niet.. zie ik miss iets over het hoofd?

Dank bij voorbaat

  • Daos
  • Registratie: Oktober 2004
  • Niet online
Uit de help:
IsNull Function
...
Important Use the IsNull function to determine whether an expression contains a Null value. Expressions that you might expect to evaluate to True under some circumstances, such as If Var = Null and If Var <> Null, are always False. This is because any expression containing a Null is itself Null and, therefore, False.