Hi, I have an Unbound Update/Edit form that Does not allow me to update with null values. I only have two required fields. Any suggestions appreciated.
Code:
Private Sub cmdSave_Click()
'**** Save Changes ****
Dim db As DAO.Database
Dim strSQL As String
Dim dte As Variant
Dim Name As String
Set db = CurrentDb
If Len(txtIDNum.Value) < 1 Then
MsgBox "Please Enter the Card No."
Exit Sub
End If
If Len(txtExpDte.Value) = "" Then
MsgBox "Please Enter the Expire Date"
Exit Sub
End If
strSQL = "UPDATE InboundID_Cards "
strSQL = strSQL & "SET CardName= '" & Me!txtcardname & "'"
strSQL = strSQL & ", [Card No#]= " & Me!txtIDNum & ""
strSQL = strSQL & ", Expiration= #" & Me!txtExpDte & "#"
strSQL = strSQL & ", Distributed= #" & Me!txtDistributedDte & "#"
strSQL = strSQL & ", Returned= #" & Me!txtReturnedDte & "#"
strSQL = strSQL & ", Consultant= '" & Me!txtConsult & "'"
strSQL = strSQL & ", Team= '" & Me!txtTeam & "'"
strSQL = strSQL & ", SSNUM= '" & Me!txtSSNUM & "'"
strSQL = strSQL & ", Supervisor= '" & Me!txtSupervisor & "'"
strSQL = strSQL & ", Floor= " & Me!txtFloor & ""
strSQL = strSQL & ", FloorAccess= '" & Me!txtFloorAccess & "'"
strSQL = strSQL & " WHERE CardName= '" & [CboFind] & "'"
Debug.Print strSQL
db.Execute strSQL
Me!CboFind.Requery
strSQL = db.RecordsAffected
MsgBox "Card Name" & Me!txtcardname & " Has Been Edited"
setDefaults
Set db = Nothing
Me!txtcardname.SetFocus
End Sub
Code:
Private Sub cmdSave_Click()
'**** Save Changes ****
Dim db As DAO.Database
Dim strSQL As String
Dim dte As Variant
Dim Name As String
Set db = CurrentDb
If Len(txtIDNum.Value) < 1 Then
MsgBox "Please Enter the Card No."
Exit Sub
End If
If Len(txtExpDte.Value) = "" Then
MsgBox "Please Enter the Expire Date"
Exit Sub
End If
strSQL = "UPDATE InboundID_Cards "
strSQL = strSQL & "SET CardName= '" & Me!txtcardname & "'"
strSQL = strSQL & ", [Card No#]= " & Me!txtIDNum & ""
strSQL = strSQL & ", Expiration= #" & Me!txtExpDte & "#"
strSQL = strSQL & ", Distributed= #" & Me!txtDistributedDte & "#"
strSQL = strSQL & ", Returned= #" & Me!txtReturnedDte & "#"
strSQL = strSQL & ", Consultant= '" & Me!txtConsult & "'"
strSQL = strSQL & ", Team= '" & Me!txtTeam & "'"
strSQL = strSQL & ", SSNUM= '" & Me!txtSSNUM & "'"
strSQL = strSQL & ", Supervisor= '" & Me!txtSupervisor & "'"
strSQL = strSQL & ", Floor= " & Me!txtFloor & ""
strSQL = strSQL & ", FloorAccess= '" & Me!txtFloorAccess & "'"
strSQL = strSQL & " WHERE CardName= '" & [CboFind] & "'"
Debug.Print strSQL
db.Execute strSQL
Me!CboFind.Requery
strSQL = db.RecordsAffected
MsgBox "Card Name" & Me!txtcardname & " Has Been Edited"
setDefaults
Set db = Nothing
Me!txtcardname.SetFocus
End Sub