I have a main and subform. I have text boxes in the main form that will allow me to add/edit information into the subform. Add works fine but when I try to edit a record, the information of the selected record shows up in the textbox like I want to but when I try to update, I get datatype error. Also when I try to delete a record I also get a datatype error.
Im trying to copy the work one of my partners for a previous project did (CarDealership). Im hoping to get similar functionality into the KeyInventory DB.
Here's the file im working on: jumpshare. com/b/t7Lot8
This is the code for the add/update button:
This is the code for the Delete button:
Im trying to copy the work one of my partners for a previous project did (CarDealership). Im hoping to get similar functionality into the KeyInventory DB.
Here's the file im working on: jumpshare. com/b/t7Lot8
This is the code for the add/update button:
Code:
Private Sub cmdAdd_Click()
If Me.keyID.Tag & "" = "" Then
CurrentDb.Execute "INSERT INTO KEYS(KEY_ID, ROOM, DRAWER)" & _
" VALUES(" & Me.keyID & ",'" & Me.roomID & "'," & Me.drawerID & ")"
subKey.Form.Requery
Else
CurrentDb.Execute "UPDATE KEYS " & _
" SET KEY_ID=" & Me.keyID & _
", ROOM='" & Me.roomID & "'" & _
", DRAWER='" & Me.drawerID & "'" & _
" WHERE KEY_ID=" & Me.keyID.Tag
End If
cmdReset_Click
subKey.Form.Requery
End Sub
This is the code for the Delete button:
Code:
Private Sub cmdDelete_Click()
If Not (Me.subKey.Form.Recordset.EOF And Me.subKey.Form.Recordset.BOF) Then
If MsgBox("Confirm Deletion?", vbYesNo) = vbYes Then
CurrentDb.Execute "DELETE FROM KEYS" & _
" WHERE KEY_ID=" & Me.subKey.Form.Recordset.Fields("KEY_ID")
Me.subKey.Form.Requery
End If
End If
End Sub