13. juni 2002 - 10:13Der er
5 kommentarer og 1 løsning
VBA
Jeg har et problem med dette VBA til Access 2000. Jeg kan ikke finde ud af at få slettet den ene "Record" i Files-tabellen.
Private Sub deleting_Click()
If IsNull(Me!deletename) Then MsgBox ("Error! You Need To Enter A Number To Delete") Else Call CompareRecords(Me!deletename) End If End Sub
Public Function CompareRecords(ID1 As String) Dim rs1 As DAO.Recordset Dim Besked As String 'DoCmd.SetWarnings False Set rs1 = CurrentDb.OpenRecordset("Select * From Files Where DeleteNr = '" & ID1 & "'", dbOpenSnapshot) If rs1.RecordCount = 0 Then MsgBox ("Error! You Need To Enter A Number That Exists") Exit Function Else answer = MsgBox("Are You Sure That You Want To Delete The File", vbYesNo) If Not answer = 6 Then MsgBox ("Delete Was Cancelled") Exit Function Else -----> 'Delete record in Files table. <------- End If End If 'DoCmd.SetWarnings True rs1.Close Set rs1 = Nothing End Function
Terry... yeah i know. But if you look at the sentence then you can see its a comment :) I need the sql-command to get the record deleted. And in the sentence: Set rs1 = CurrentDb.OpenRecordset("Select * From Files Where DeleteNr = '" & ID1 & "'", dbOpenSnapshot) I get an error message too. Runtime error 3464. Data Type mismatch in criteria expression. Can you help me with that?
Docmd.runsql "DELETE FROM YOURTABLE WHERE DeleteNr = '" & ID1 & "'" and if ID is NUMERIC then Docmd.runsql "DELETE FROM YOURTABLE WHERE DeleteNr = " & ID1
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.