Deleting Records

  • Thread starter Thread starter Sheldon
  • Start date Start date
S

Sheldon

I have a form with bound controls. When I delete a record
and the record is not the last record, everything works
just fine. BUT, if the record I'm deleting is the last
record, the system seems to get lost. The record is
deleted, but I can't get to another record without exiting
the system and re-entering. I have even tried
Me.Recordset.MovePrevious
with no results.

Any suggestions.

Thanks
 
Well, if the form has no records, then you probably should close it.

It really depe3ndons on how you mange/allow users to add new reocrds.

I don't know how you do the delete, but I would consoder some code like:

dim strSql as string

if isnull(me.Id) = false then
strSQl = "delete * from tblCustomer were id = " & me.Id
currentdb.execute strSQL
ME.REQUERY
if me.recordsetclone.RecordCount = 0 then
docmd.Close acForm,me.name
endif
endif

I mean, what happens when the table is empty, and you open the form? Is the
user given a option to add records, or do you use the navigation buttons?

I usually give the user a search screen to "look" for a rerecord, display a
list of matches, and then let the user LOOK AT the one record in the form.
Of course, if during the searching process the name is NOT found, then I
give a add record button. However, as a matter of good performance, and good
UI, I don't use the navigation buttons to add new records.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top