Two Access Questions - Entering and Deleting Data

Two Access Questions - Entering and Deleting Data

am 07.12.2007 19:55:21 von robertns5411

I have two questions:

1) Say I have a form bound to a table. Assume the user is entering
data into a new record at the bottom of the form. Now, suppose the
user clicks a button on the form while he's still entering data and
hasn't yet saved the record that he is modifying. How can the
button's click event procedure test to know that the user is in the
middle of entering new data? I've tried testing against the form's
recordset's AbsolutePosition, BOF, and EOF with no luck.

2) How can one do in code exactly what the DEL key does on a form?
The DEL key on a form allows you, among other things, to delete a
modified record such as the one describe in my first question. Using
the recordset's Delete method doesn't do this. How would one write
an event procedure for a button that does exactly what the DEL key
does when used in a form?

Thanks.

Re: Two Access Questions - Entering and Deleting Data

am 07.12.2007 20:49:43 von Rich P

One trick would be to use an Unbound Form. Add data to this form which
would have unbound textboxes and a button for new record (and/or buttons
for movenext, moveprev) then then when you move to a new record or any
other record
-- that would trigger a statement like

DoCmd.RunSql "Insert Into tblx(fld1, fld2, fld...) Select txt1, txt2,
txt..."


You can also have your own delete button which would just clear out the
textboxes (because you have not yet added the data to the table). Or if
the data is already in the table and you want to remove a record then:

DoCmd.RunSql "Delete * From tblx Where RowID = " & txtRowID

Another thing you could do for deleting a record(s) if the form is a
bound form is to view your form in datasheet view and select a record
and just press the Delete key. Go to the view menu at the top of Access
and select Datasheet View


Rich

*** Sent via Developersdex http://www.developersdex.com ***

Re: Two Access Questions - Entering and Deleting Data

am 07.12.2007 21:08:43 von u28780

I have two questions:

(1)

If Me.Dirty Then
'Do your thing here if in the middle of a new record
End If

(2)
Me.Undo

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via http://www.accessmonster.com