従業員が予定のグルーミング時間を入力するためのフォームを作成しようとしています。なぜ新しいレコードの更新を許可しないのですか
私は同じペットが新しい日付に任命され、Microsoft Visual Basicランタイムエラー3022を取得し、新しいエントリを追加しない限り、動作しました。
ここでは何が起こっているのですか?
Private Sub cmdNew_Click()
' Error check for empty comboboxes
If IsNull(CmbPetName) = True Then
MsgBox ("Pick A Pet For This Operation")
Exit Sub
ElseIf IsNull(CmbPEmplye) = True Then
MsgBox ("Pick A Prep Employee For This Operation")
Exit Sub
ElseIf IsNull(CmbPTime) = True Then
MsgBox ("Pick A Prep Time For This Operation")
Exit Sub
ElseIf IsNull(CmbBEmplye) = True Then
MsgBox ("Pick A Bath Employee For This Operation")
Exit Sub
ElseIf IsNull(CmbBTime) = True Then
MsgBox ("Pick A Bath Time For This Operation")
Exit Sub
ElseIf IsNull(CmbDEmplye) = True Then
MsgBox ("Pick A Dry Employee For This Operation")
Exit Sub
ElseIf IsNull(CmbDTime) = True Then
MsgBox ("Pick A Dry Time For This Operation")
Exit Sub
ElseIf IsNull(CmbGEmplye) = True Then
MsgBox ("Pick A Groom Employee For This Operation")
Exit Sub
ElseIf IsNull(CmbGTime) = True Then
MsgBox ("Pick A Groom Time For This Operation")
Exit Sub
End If
'Set variables for error checking duplicates
Dim pid As String
Dim aptdate As Date
pid = CmbPetName.Column(2)
'MsgBox (pid)
aptdate = txtAptDate.Value
'MsgBox (aptdate)
Dim strCriteria As String
'Set Criteria for DCount()
strCriteria = "([PetID] = '" & pid & "') And ([ApptDate] = #" & aptdate & "#)"
'MsgBox (strCriteria)
'Error checking for duplicates
If DCount("[PetID]", "[TimeLog]", strCriteria) > 0 Then
MsgBox ("Record Already Exists")
Exit Sub
End If
'Set variables to record entries
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("TimeLog", dbOpenTable)
'Add entries to Table TimeLog
rs.AddNew
rs!PetID = CmbPetName.Value
rs!PetName = Me.CmbPetName.Column(0)
rs!ApptDate = txtAptDate.Value
rs!ptime = CmbPTime.Value
rs!PEmplyee = CmbPEmplye.Value
rs!btime = CmbBTime.Value
rs!BEmplyee = CmbBEmplye.Value
rs!dtime = CmbDTime.Value
rs!DEmplyee = CmbDEmplye.Value
rs!gtime = CmbGTime.Value
rs!GEmplyee = CmbGEmplye.Value
rs.Update
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
Me.CmbPetName = Null
Me.CmbPEmplye = Null
Me.CmbBEmplye = Null
Me.CmbDEmplye = Null
Me.CmbGEmplye = Null
Me.CmbPTime = Null
Me.CmbBTime = Null
Me.CmbDTime = Null
Me.CmbGTime = Null
End Sub
実行時は、rs.update行で発生します。
エラーメッセージの*テキスト*とは何ですか? –