Hi everyone,
I was hoping someone could help me with the following.
I have a form with a combo box, the user chooses from the combo box and clicks the search button and it populates a number of text fields with the information regarding the item in the combo box.
I also have a delete button which will allow the user to delete the record if required. The unique field is the primary key which is an autonumber therefore i would like to delete using this field. Below is the code i use but i seem to get an error saying "Data Type Mismatch". Can someone see where i am may be going wrong.
Thanks
Nim
I was hoping someone could help me with the following.
I have a form with a combo box, the user chooses from the combo box and clicks the search button and it populates a number of text fields with the information regarding the item in the combo box.
I also have a delete button which will allow the user to delete the record if required. The unique field is the primary key which is an autonumber therefore i would like to delete using this field. Below is the code i use but i seem to get an error saying "Data Type Mismatch". Can someone see where i am may be going wrong.
Code:
Dim db As DAO.Database, SQL As String
Dim strInput As String
Dim strMsg As String
strMsg = "Please Enter Password to Delete Record?" & vbCrLf & vbLf & _
"Please key the programmer's password."
strInput = InputBox(Prompt:=strMsg, Title:="Delete Record")
If strInput = "test" Then
If MsgBox("Do You Really want to delete key assigned to " & Forms!frmkeys.[MainFilter] & "?", vbQuestion + vbYesNo) = vbYes Then
Set db = CurrentDb
SQL = "DELETE ID " & _
"FROM tblkeys " & _
"WHERE ([ID]) = '" & Me!Text53 & "';"
db.Execute SQL, dbFailOnError
Set db = Nothing
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
MsgBox ("Record Has Been Deleted")
DoCmd.Close
End If
Else
MsgBox ("Password Incorrect Please Talk to Administrator")
Exit Sub
End If
Thanks
Nim