By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,705 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,705 IT Pros & Developers. It's quick & easy.

Two Access Questions - Entering and Deleting Data

P: n/a
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.
Dec 7 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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 ***
Dec 7 '07 #2

P: n/a
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

Dec 7 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.