Schlingel
Registered User.
- Local time
- Today, 06:23
- Joined
- Oct 26, 2006
- Messages
- 32
Hi!
I really appreciate my being the part of this community. I also appreciate ur help. Thanks, i have already learned much.
Now i have a small problem and i am asking for ur help.
I have a form. The user can input hours (options group from 1 to 8), module (combobox, only list entries) and comment (combobox, user and list entries).
I have written the following code to check if the records with the hour are already in the table, so the user could have only one record for hour #1, one record for hour#2 etc. But somehow it checks only for hour#1. I don't know why. Could u help me, please?
Rahmen44 is the name of my optionsgroup
As always, thanks in advance
I really appreciate my being the part of this community. I also appreciate ur help. Thanks, i have already learned much.
Now i have a small problem and i am asking for ur help.
I have a form. The user can input hours (options group from 1 to 8), module (combobox, only list entries) and comment (combobox, user and list entries).
I have written the following code to check if the records with the hour are already in the table, so the user could have only one record for hour #1, one record for hour#2 etc. But somehow it checks only for hour#1. I don't know why. Could u help me, please?
Code:
Private Sub Form_AfterInsert()
Dim items As Long
Dim items2 As String
Dim items3 As Long
Dim adate As String
Dim adate1 As String
Dim adate2 As String
Dim adate3 As String
Set db = CurrentDb
Set rst = db.OpenRecordset("Nachweis")
adate1 = Format(Forms!Nachweis!Datum, "mm")
adate2 = Format(Forms!Nachweis!Datum, "dd")
adate3 = Format(Forms!Nachweis!Datum, "yyyy")
adate = adate1 & "/" & adate2 & "/" & adate3
items = DCount("[Stunde]", "Nachweis", "[Datum]= " & "#" & adate & "#" & "")
MsgBox items
If items = 0 Then
Me.Rahmen44.Value = 1
GoTo ENDE
Else: End If
items2 = DLookup("[Stunde]", "Nachweis", "[Datum]= " & "#" & adate & "#" & "" And "[Stunde]= '" & "Me.Rahmen44.Value" & "'")
MsgBox items2
If items <= 8 Then
If items2 = Me.Rahmen44.Value Then
MsgBox "Die Eingabe für diese Stunde existiert schon"
Me.Rahmen44.Value = items2 + 1
Else: End If
Else
MsgBox "Für diesen Tag haben Sie schon 8 Eingaben"
End If
ENDE:
End Sub
As always, thanks in advance