PC Review


Reply
Thread Tools Rate Thread

Delete record acCmdDeleteRecord not removing record: Form

 
 
=?Utf-8?B?c2NyYXRjaHRyYXg=?=
Guest
Posts: n/a
 
      6th Mar 2006
I've got a command button that uses the following to delete a record:

Response = MsgBox("Delete The Current Material?", vbYesNo, "Atlantic County
Office Of GIS")
If Response = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
MaterialSum
DoCmd.RunCommand acCmdCloseWindow
ElseIf Response = vbNo Then
Exit Sub
End If
Where MaterialSum is a module that totals the price to the main form using
Dsum. It works, sort of... The record is zero'd out so that all the fields
are empty but it is not deleted from the table. Is this because I have
controls that are locked? Or rather, are there any suggestions as to why
this might be happening?
--
http://njgin.aclink.org
 
Reply With Quote
 
 
 
 
=?Utf-8?B?bGRpYXo=?=
Guest
Posts: n/a
 
      6th Mar 2006
You need run a SQL like this:

DELETE [table.*]
FROM table
WHERE criteria

maybe this help you


--
Lorenzo DÃ*az
Cad Technician


"scratchtrax" wrote:

> I've got a command button that uses the following to delete a record:
>
> Response = MsgBox("Delete The Current Material?", vbYesNo, "Atlantic County
> Office Of GIS")
> If Response = vbYes Then
> DoCmd.RunCommand acCmdDeleteRecord
> MaterialSum
> DoCmd.RunCommand acCmdCloseWindow
> ElseIf Response = vbNo Then
> Exit Sub
> End If
> Where MaterialSum is a module that totals the price to the main form using
> Dsum. It works, sort of... The record is zero'd out so that all the fields
> are empty but it is not deleted from the table. Is this because I have
> controls that are locked? Or rather, are there any suggestions as to why
> this might be happening?
> --
> http://njgin.aclink.org

 
Reply With Quote
 
=?Utf-8?B?c2NyYXRjaHRyYXg=?=
Guest
Posts: n/a
 
      6th Mar 2006
Well, its an Event Procedure from a command button that runs this code. Do I
then need to run an SQL statement to remove the record from the table?
--
http://njgin.aclink.org


"ldiaz" wrote:

> You need run a SQL like this:
>
> DELETE [table.*]
> FROM table
> WHERE criteria
>
> maybe this help you
>
>
> --
> Lorenzo DÃ*az
> Cad Technician
>
>
> "scratchtrax" wrote:
>
> > I've got a command button that uses the following to delete a record:
> >
> > Response = MsgBox("Delete The Current Material?", vbYesNo)
> > If Response = vbYes Then
> > DoCmd.RunCommand acCmdDeleteRecord
> > MaterialSum
> > DoCmd.RunCommand acCmdCloseWindow
> > ElseIf Response = vbNo Then
> > Exit Sub
> > End If
> > Where MaterialSum is a module that totals the price to the main form using
> > Dsum. It works, sort of... The record is zero'd out so that all the fields
> > are empty but it is not deleted from the table. Is this because I have
> > controls that are locked? Or rather, are there any suggestions as to why
> > this might be happening?
> > --
> > http://njgin.aclink.org

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      6th Mar 2006
No, you do not need to execute a SQL statement if you are deleting a record
from a bound form.

The record cannot be "deleted" if it is a new one (unsaved new record). If
it is dirty at all, Access has to undo or save it. Saving (the default)
makes no sense, particularly as it might save, so try somthing like this:

If Me.Dirty Then
Me.Undo
End If
If Not Me.NewRecord Then
RunCommand acCmdDeleteRecord
MaterialSum
DoCmd.Close acForm, Me.Name
End If

That should generate the built-in delete confirmation message. You can have
your custom one as well if you wish.

If you still believe the record is not being deleted, add this line just
before the RunCommand:
Debug.Print Me.[ID]
substituting your primary key field name for ID. You should then see the
primary key value of the record that was deleted in the Immediate Window
(Ctrl+G) after this runs. You can then investigate whether the remaining
blank record is the same one, or is being caused by some other means (e.g.
faulty code in the Current event of the Form.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"scratchtrax" <(E-Mail Removed)> wrote in message
news:A1EE1B69-CCC8-41E5-BED5-(E-Mail Removed)...
> Well, its an Event Procedure from a command button that runs this code.
> Do I
> then need to run an SQL statement to remove the record from the table?
> --
> http://njgin.aclink.org
>
>
> "ldiaz" wrote:
>
>> You need run a SQL like this:
>>
>> DELETE [table.*]
>> FROM table
>> WHERE criteria
>>
>> maybe this help you
>>
>>
>> --
>> Lorenzo Díaz
>> Cad Technician
>>
>>
>> "scratchtrax" wrote:
>>
>> > I've got a command button that uses the following to delete a record:
>> >
>> > Response = MsgBox("Delete The Current Material?", vbYesNo)
>> > If Response = vbYes Then
>> > DoCmd.RunCommand acCmdDeleteRecord
>> > MaterialSum
>> > DoCmd.RunCommand acCmdCloseWindow
>> > ElseIf Response = vbNo Then
>> > Exit Sub
>> > End If
>> > Where MaterialSum is a module that totals the price to the main form
>> > using
>> > Dsum. It works, sort of... The record is zero'd out so that all the
>> > fields
>> > are empty but it is not deleted from the table. Is this because I have
>> > controls that are locked? Or rather, are there any suggestions as to
>> > why
>> > this might be happening?
>> > --
>> > http://njgin.aclink.org



 
Reply With Quote
 
=?Utf-8?B?c2NyYXRjaHRyYXg=?=
Guest
Posts: n/a
 
      6th Mar 2006
Thanks for the response Tom. I am reluctant though... The record I am
trying to delete is the many part of a one-to-many relationship. What would
be the syntax for setting the criteria to the current record and only the
current record? Or, wouldn't that matter? I am using the docmd.runcommand
acCmdDeleteRecord which erases it but doen't remove it from the table.
--
http://njgin.aclink.org


"Tom Wickerath" wrote:

> Make that the 3.6 Object Library for Access 2000/2002/2003. Temporarily
> confused it with JET 4.0. Oh, the ravages of aging....sigh.
>
>
> Tom
>
> http://www.access.qbuilt.com/html/ex...tributors.html
> http://www.access.qbuilt.com/html/search.html
> __________________________________________
>
>
> "Tom Wickerath" wrote:
>
> > Nope. Just do something like this:
> >
> > Private Sub cmdDeleteRecord_Click()
> > On Error GoTo ProcError
> >
> > Dim strSQL As String
> >
> > strSQL = "DELETE [table.*] FROM table WHERE criteria"
> > CurrentDb.Execute strSQL, dbFailOnError
> >
> > ExitProc:
> > Exit Sub
> > ProcError:
> > MsgBox "Error " & Err.Number & ": " & Err.Description, _
> > vbCritical, "Error in procedure cmdDeleteRecord_Click..."
> > Resume ExitProc
> > End Sub
> > ******************************
> >
> > An example strSQL statement for a numeric primary key would be the following:
> >
> > strSQL = "DELETE [Categories.*] FROM Categories " _
> > & "WHERE CategoryID = " & Me.CategoryID
> >
> > If the criteria involves a text value, then you'll need to wrap the criteria
> > in quotes or use Chr(34), as in the following examples:
> >
> > strSQL = "DELETE [Categories.*] FROM Categories " _
> > & "WHERE CategoryName = '" & Me.CategoryName & "'"
> >
> > or
> >
> > strSQL = "DELETE [Categories.*] FROM Categories " _
> > & "WHERE CategoryName = " & Chr(34) & Me.CategoryName & Chr(34)
> >
> >
> > In order to use the optional dbFailOnError parameter, you will need to set a
> > reference to the "Microsoft DAO 4.0 Object Library" (or version 3.51 for
> > Access 97).
> >
> >
> > Tom
> >
> > http://www.access.qbuilt.com/html/ex...tributors.html
> > http://www.access.qbuilt.com/html/search.html
> > __________________________________________
> >
> >
> > "scratchtrax" wrote:
> >
> > > Well, its an Event Procedure from a command button that runs this code. Do I
> > > then need to run an SQL statement to remove the record from the table?
> > > --
> > > http://njgin.aclink.org
> > >
> > >
> > > "ldiaz" wrote:
> > >
> > > > You need run a SQL like this:
> > > >
> > > > DELETE [table.*]
> > > > FROM table
> > > > WHERE criteria
> > > >
> > > > maybe this help you
> > > >
> > > >
> > > > --
> > > > Lorenzo DÃ*az
> > > > Cad Technician
> > > >
> > > >
> > > > "scratchtrax" wrote:
> > > >
> > > > > I've got a command button that uses the following to delete a record:
> > > > >
> > > > > Response = MsgBox("Delete The Current Material?", vbYesNo)
> > > > > If Response = vbYes Then
> > > > > DoCmd.RunCommand acCmdDeleteRecord
> > > > > MaterialSum
> > > > > DoCmd.RunCommand acCmdCloseWindow
> > > > > ElseIf Response = vbNo Then
> > > > > Exit Sub
> > > > > End If
> > > > > Where MaterialSum is a module that totals the price to the main form using
> > > > > Dsum. It works, sort of... The record is zero'd out so that all the fields
> > > > > are empty but it is not deleted from the table. Is this because I have
> > > > > controls that are locked? Or rather, are there any suggestions as to why
> > > > > this might be happening?
> > > > > --
> > > > > http://njgin.aclink.org

 
Reply With Quote
 
=?Utf-8?B?c2NyYXRjaHRyYXg=?=
Guest
Posts: n/a
 
      6th Mar 2006
I guess I could add some sort of clean up routine at the end of it where I'd
delete all records with a zero value in some field maybe? What do you all
think, am I not doing something correctly? It sure does feel like it ;-)
--
http://njgin.aclink.org


"scratchtrax" wrote:

> Thank you for the response Allen. I actually saw this on a previous thread
> and I plan on using it for the unsaved record.
>
> This is a saved record that I am attempting to delete and I am using
> something very similar to the second part of your argument. It does erase
> it, but it doesn't remove it from the table. I'm using 2000 and I have some
> controls on the form that are locked. Do you think this has anything to do
> with it?
> --
> http://njgin.aclink.org
>
>
> "Allen Browne" wrote:
>
> > No, you do not need to execute a SQL statement if you are deleting a record
> > from a bound form.
> >
> > The record cannot be "deleted" if it is a new one (unsaved new record). If
> > it is dirty at all, Access has to undo or save it. Saving (the default)
> > makes no sense, particularly as it might save, so try somthing like this:
> >
> > If Me.Dirty Then
> > Me.Undo
> > End If
> > If Not Me.NewRecord Then
> > RunCommand acCmdDeleteRecord
> > MaterialSum
> > DoCmd.Close acForm, Me.Name
> > End If
> >
> > That should generate the built-in delete confirmation message. You can have
> > your custom one as well if you wish.
> >
> > If you still believe the record is not being deleted, add this line just
> > before the RunCommand:
> > Debug.Print Me.[ID]
> > substituting your primary key field name for ID. You should then see the
> > primary key value of the record that was deleted in the Immediate Window
> > (Ctrl+G) after this runs. You can then investigate whether the remaining
> > blank record is the same one, or is being caused by some other means (e.g.
> > faulty code in the Current event of the Form.)
> >
> > --
> > Allen Browne - Microsoft MVP. Perth, Western Australia.
> > Tips for Access users - http://allenbrowne.com/tips.html
> > Reply to group, rather than allenbrowne at mvps dot org.
> >
> > "scratchtrax" <(E-Mail Removed)> wrote in message
> > news:A1EE1B69-CCC8-41E5-BED5-(E-Mail Removed)...
> > > Well, its an Event Procedure from a command button that runs this code.
> > > Do I
> > > then need to run an SQL statement to remove the record from the table?
> > > --
> > > http://njgin.aclink.org
> > >
> > >
> > > "ldiaz" wrote:
> > >
> > >> You need run a SQL like this:
> > >>
> > >> DELETE [table.*]
> > >> FROM table
> > >> WHERE criteria
> > >>
> > >> maybe this help you
> > >>
> > >>
> > >> --
> > >> Lorenzo DÃ*az
> > >> Cad Technician
> > >>
> > >>
> > >> "scratchtrax" wrote:
> > >>
> > >> > I've got a command button that uses the following to delete a record:
> > >> >
> > >> > Response = MsgBox("Delete The Current Material?", vbYesNo)
> > >> > If Response = vbYes Then
> > >> > DoCmd.RunCommand acCmdDeleteRecord
> > >> > MaterialSum
> > >> > DoCmd.RunCommand acCmdCloseWindow
> > >> > ElseIf Response = vbNo Then
> > >> > Exit Sub
> > >> > End If
> > >> > Where MaterialSum is a module that totals the price to the main form
> > >> > using
> > >> > Dsum. It works, sort of... The record is zero'd out so that all the
> > >> > fields
> > >> > are empty but it is not deleted from the table. Is this because I have
> > >> > controls that are locked? Or rather, are there any suggestions as to
> > >> > why
> > >> > this might be happening?
> > >> > --
> > >> > http://njgin.aclink.org

> >
> >
> >

 
Reply With Quote
 
=?Utf-8?B?VG9tIFdpY2tlcmF0aA==?=
Guest
Posts: n/a
 
      6th Mar 2006
Nope. Just do something like this:

Private Sub cmdDeleteRecord_Click()
On Error GoTo ProcError

Dim strSQL As String

strSQL = "DELETE [table.*] FROM table WHERE criteria"
CurrentDb.Execute strSQL, dbFailOnError

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure cmdDeleteRecord_Click..."
Resume ExitProc
End Sub
******************************

An example strSQL statement for a numeric primary key would be the following:

strSQL = "DELETE [Categories.*] FROM Categories " _
& "WHERE CategoryID = " & Me.CategoryID

If the criteria involves a text value, then you'll need to wrap the criteria
in quotes or use Chr(34), as in the following examples:

strSQL = "DELETE [Categories.*] FROM Categories " _
& "WHERE CategoryName = '" & Me.CategoryName & "'"

or

strSQL = "DELETE [Categories.*] FROM Categories " _
& "WHERE CategoryName = " & Chr(34) & Me.CategoryName & Chr(34)


In order to use the optional dbFailOnError parameter, you will need to set a
reference to the "Microsoft DAO 4.0 Object Library" (or version 3.51 for
Access 97).


Tom

http://www.access.qbuilt.com/html/ex...tributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________


"scratchtrax" wrote:

> Well, its an Event Procedure from a command button that runs this code. Do I
> then need to run an SQL statement to remove the record from the table?
> --
> http://njgin.aclink.org
>
>
> "ldiaz" wrote:
>
> > You need run a SQL like this:
> >
> > DELETE [table.*]
> > FROM table
> > WHERE criteria
> >
> > maybe this help you
> >
> >
> > --
> > Lorenzo DÃ*az
> > Cad Technician
> >
> >
> > "scratchtrax" wrote:
> >
> > > I've got a command button that uses the following to delete a record:
> > >
> > > Response = MsgBox("Delete The Current Material?", vbYesNo)
> > > If Response = vbYes Then
> > > DoCmd.RunCommand acCmdDeleteRecord
> > > MaterialSum
> > > DoCmd.RunCommand acCmdCloseWindow
> > > ElseIf Response = vbNo Then
> > > Exit Sub
> > > End If
> > > Where MaterialSum is a module that totals the price to the main form using
> > > Dsum. It works, sort of... The record is zero'd out so that all the fields
> > > are empty but it is not deleted from the table. Is this because I have
> > > controls that are locked? Or rather, are there any suggestions as to why
> > > this might be happening?
> > > --
> > > http://njgin.aclink.org

 
Reply With Quote
 
=?Utf-8?B?VG9tIFdpY2tlcmF0aA==?=
Guest
Posts: n/a
 
      6th Mar 2006
Make that the 3.6 Object Library for Access 2000/2002/2003. Temporarily
confused it with JET 4.0. Oh, the ravages of aging....sigh.


Tom

http://www.access.qbuilt.com/html/ex...tributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________


"Tom Wickerath" wrote:

> Nope. Just do something like this:
>
> Private Sub cmdDeleteRecord_Click()
> On Error GoTo ProcError
>
> Dim strSQL As String
>
> strSQL = "DELETE [table.*] FROM table WHERE criteria"
> CurrentDb.Execute strSQL, dbFailOnError
>
> ExitProc:
> Exit Sub
> ProcError:
> MsgBox "Error " & Err.Number & ": " & Err.Description, _
> vbCritical, "Error in procedure cmdDeleteRecord_Click..."
> Resume ExitProc
> End Sub
> ******************************
>
> An example strSQL statement for a numeric primary key would be the following:
>
> strSQL = "DELETE [Categories.*] FROM Categories " _
> & "WHERE CategoryID = " & Me.CategoryID
>
> If the criteria involves a text value, then you'll need to wrap the criteria
> in quotes or use Chr(34), as in the following examples:
>
> strSQL = "DELETE [Categories.*] FROM Categories " _
> & "WHERE CategoryName = '" & Me.CategoryName & "'"
>
> or
>
> strSQL = "DELETE [Categories.*] FROM Categories " _
> & "WHERE CategoryName = " & Chr(34) & Me.CategoryName & Chr(34)
>
>
> In order to use the optional dbFailOnError parameter, you will need to set a
> reference to the "Microsoft DAO 4.0 Object Library" (or version 3.51 for
> Access 97).
>
>
> Tom
>
> http://www.access.qbuilt.com/html/ex...tributors.html
> http://www.access.qbuilt.com/html/search.html
> __________________________________________
>
>
> "scratchtrax" wrote:
>
> > Well, its an Event Procedure from a command button that runs this code. Do I
> > then need to run an SQL statement to remove the record from the table?
> > --
> > http://njgin.aclink.org
> >
> >
> > "ldiaz" wrote:
> >
> > > You need run a SQL like this:
> > >
> > > DELETE [table.*]
> > > FROM table
> > > WHERE criteria
> > >
> > > maybe this help you
> > >
> > >
> > > --
> > > Lorenzo DÃ*az
> > > Cad Technician
> > >
> > >
> > > "scratchtrax" wrote:
> > >
> > > > I've got a command button that uses the following to delete a record:
> > > >
> > > > Response = MsgBox("Delete The Current Material?", vbYesNo)
> > > > If Response = vbYes Then
> > > > DoCmd.RunCommand acCmdDeleteRecord
> > > > MaterialSum
> > > > DoCmd.RunCommand acCmdCloseWindow
> > > > ElseIf Response = vbNo Then
> > > > Exit Sub
> > > > End If
> > > > Where MaterialSum is a module that totals the price to the main form using
> > > > Dsum. It works, sort of... The record is zero'd out so that all the fields
> > > > are empty but it is not deleted from the table. Is this because I have
> > > > controls that are locked? Or rather, are there any suggestions as to why
> > > > this might be happening?
> > > > --
> > > > http://njgin.aclink.org

 
Reply With Quote
 
=?Utf-8?B?c2NyYXRjaHRyYXg=?=
Guest
Posts: n/a
 
      6th Mar 2006
Thank you for the response Allen. I actually saw this on a previous thread
and I plan on using it for the unsaved record.

This is a saved record that I am attempting to delete and I am using
something very similar to the second part of your argument. It does erase
it, but it doesn't remove it from the table. I'm using 2000 and I have some
controls on the form that are locked. Do you think this has anything to do
with it?
--
http://njgin.aclink.org


"Allen Browne" wrote:

> No, you do not need to execute a SQL statement if you are deleting a record
> from a bound form.
>
> The record cannot be "deleted" if it is a new one (unsaved new record). If
> it is dirty at all, Access has to undo or save it. Saving (the default)
> makes no sense, particularly as it might save, so try somthing like this:
>
> If Me.Dirty Then
> Me.Undo
> End If
> If Not Me.NewRecord Then
> RunCommand acCmdDeleteRecord
> MaterialSum
> DoCmd.Close acForm, Me.Name
> End If
>
> That should generate the built-in delete confirmation message. You can have
> your custom one as well if you wish.
>
> If you still believe the record is not being deleted, add this line just
> before the RunCommand:
> Debug.Print Me.[ID]
> substituting your primary key field name for ID. You should then see the
> primary key value of the record that was deleted in the Immediate Window
> (Ctrl+G) after this runs. You can then investigate whether the remaining
> blank record is the same one, or is being caused by some other means (e.g.
> faulty code in the Current event of the Form.)
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "scratchtrax" <(E-Mail Removed)> wrote in message
> news:A1EE1B69-CCC8-41E5-BED5-(E-Mail Removed)...
> > Well, its an Event Procedure from a command button that runs this code.
> > Do I
> > then need to run an SQL statement to remove the record from the table?
> > --
> > http://njgin.aclink.org
> >
> >
> > "ldiaz" wrote:
> >
> >> You need run a SQL like this:
> >>
> >> DELETE [table.*]
> >> FROM table
> >> WHERE criteria
> >>
> >> maybe this help you
> >>
> >>
> >> --
> >> Lorenzo DÃ*az
> >> Cad Technician
> >>
> >>
> >> "scratchtrax" wrote:
> >>
> >> > I've got a command button that uses the following to delete a record:
> >> >
> >> > Response = MsgBox("Delete The Current Material?", vbYesNo)
> >> > If Response = vbYes Then
> >> > DoCmd.RunCommand acCmdDeleteRecord
> >> > MaterialSum
> >> > DoCmd.RunCommand acCmdCloseWindow
> >> > ElseIf Response = vbNo Then
> >> > Exit Sub
> >> > End If
> >> > Where MaterialSum is a module that totals the price to the main form
> >> > using
> >> > Dsum. It works, sort of... The record is zero'd out so that all the
> >> > fields
> >> > are empty but it is not deleted from the table. Is this because I have
> >> > controls that are locked? Or rather, are there any suggestions as to
> >> > why
> >> > this might be happening?
> >> > --
> >> > http://njgin.aclink.org

>
>
>

 
Reply With Quote
 
=?Utf-8?B?VG9tIFdpY2tlcmF0aA==?=
Guest
Posts: n/a
 
      6th Mar 2006
> I am using the docmd.runcommand acCmdDeleteRecord which erases
> it but doen't remove it from the table.


I'm not sure where you got the idea that a record can be "erased".
Docmd.Runcommand acCmdDeleteRecord is one method of deleting records. There
are others, as you've already seen.


Tom

http://www.access.qbuilt.com/html/ex...tributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

"scratchtrax" wrote:

> Thanks for the response Tom. I am reluctant though... The record I am
> trying to delete is the many part of a one-to-many relationship. What would
> be the syntax for setting the criteria to the current record and only the
> current record? Or, wouldn't that matter? I am using the docmd.runcommand
> acCmdDeleteRecord which erases it but doen't remove it from the table.
> --
> http://njgin.aclink.org
>
>
> "Tom Wickerath" wrote:
>
> > Make that the 3.6 Object Library for Access 2000/2002/2003. Temporarily
> > confused it with JET 4.0. Oh, the ravages of aging....sigh.
> >
> >
> > Tom
> >
> > http://www.access.qbuilt.com/html/ex...tributors.html
> > http://www.access.qbuilt.com/html/search.html
> > __________________________________________
> >
> >
> > "Tom Wickerath" wrote:
> >
> > > Nope. Just do something like this:
> > >
> > > Private Sub cmdDeleteRecord_Click()
> > > On Error GoTo ProcError
> > >
> > > Dim strSQL As String
> > >
> > > strSQL = "DELETE [table.*] FROM table WHERE criteria"
> > > CurrentDb.Execute strSQL, dbFailOnError
> > >
> > > ExitProc:
> > > Exit Sub
> > > ProcError:
> > > MsgBox "Error " & Err.Number & ": " & Err.Description, _
> > > vbCritical, "Error in procedure cmdDeleteRecord_Click..."
> > > Resume ExitProc
> > > End Sub
> > > ******************************
> > >
> > > An example strSQL statement for a numeric primary key would be the following:
> > >
> > > strSQL = "DELETE [Categories.*] FROM Categories " _
> > > & "WHERE CategoryID = " & Me.CategoryID
> > >
> > > If the criteria involves a text value, then you'll need to wrap the criteria
> > > in quotes or use Chr(34), as in the following examples:
> > >
> > > strSQL = "DELETE [Categories.*] FROM Categories " _
> > > & "WHERE CategoryName = '" & Me.CategoryName & "'"
> > >
> > > or
> > >
> > > strSQL = "DELETE [Categories.*] FROM Categories " _
> > > & "WHERE CategoryName = " & Chr(34) & Me.CategoryName & Chr(34)
> > >
> > >
> > > In order to use the optional dbFailOnError parameter, you will need to set a
> > > reference to the "Microsoft DAO 4.0 Object Library" (or version 3.51 for
> > > Access 97).
> > >
> > >
> > > Tom
> > >
> > > http://www.access.qbuilt.com/html/ex...tributors.html
> > > http://www.access.qbuilt.com/html/search.html
> > > __________________________________________
> > >
> > >
> > > "scratchtrax" wrote:
> > >
> > > > Well, its an Event Procedure from a command button that runs this code. Do I
> > > > then need to run an SQL statement to remove the record from the table?
> > > > --
> > > > http://njgin.aclink.org
> > > >
> > > >
> > > > "ldiaz" wrote:
> > > >
> > > > > You need run a SQL like this:
> > > > >
> > > > > DELETE [table.*]
> > > > > FROM table
> > > > > WHERE criteria
> > > > >
> > > > > maybe this help you
> > > > >
> > > > >
> > > > > --
> > > > > Lorenzo DÃ*az
> > > > > Cad Technician
> > > > >
> > > > >
> > > > > "scratchtrax" wrote:
> > > > >
> > > > > > I've got a command button that uses the following to delete a record:
> > > > > >
> > > > > > Response = MsgBox("Delete The Current Material?", vbYesNo)
> > > > > > If Response = vbYes Then
> > > > > > DoCmd.RunCommand acCmdDeleteRecord
> > > > > > MaterialSum
> > > > > > DoCmd.RunCommand acCmdCloseWindow
> > > > > > ElseIf Response = vbNo Then
> > > > > > Exit Sub
> > > > > > End If
> > > > > > Where MaterialSum is a module that totals the price to the main form using
> > > > > > Dsum. It works, sort of... The record is zero'd out so that all the fields
> > > > > > are empty but it is not deleted from the table. Is this because I have
> > > > > > controls that are locked? Or rather, are there any suggestions as to why
> > > > > > this might be happening?
> > > > > > --
> > > > > > http://njgin.aclink.org

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Double Click record in cont. form and delete the record Anne Microsoft Access Form Coding 4 31st Dec 2009 02:27 PM
Prevent Subform from saving record or delete record when moving tomain form RussCRM Microsoft Access Form Coding 0 3rd Apr 2008 07:26 PM
Error deleting record - acCmdDeleteRecord isn't available =?Utf-8?B?VGltIFBldGVycw==?= Microsoft Access Form Coding 2 22nd Jun 2007 11:04 PM
Delete a record and save a new record from form =?Utf-8?B?TmF0aGFuIFdvbGZl?= Microsoft Access 0 22nd Jun 2007 08:06 PM
I am trying to get a form to pick up the record data from a different record to this new record Thomas Simsion Microsoft Access Forms 4 10th Nov 2003 09:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:16 AM.