Delete blank

B

bladelock

I have an input form which works well. Here is the problem, I keep track of
which user logs into the database by letting the user select his name and
password on another screen. If correct then I hide the logon screen and open
the main input screen. I hide the logon screen because I want to store the
user name and date to the input screen. The user can see the username and
date on the input screen, but can't enable it (just look at it). This works
fine, here is the problem: I have 3 other fields on the input form txtName,
txtAge, txtNotes. If the user clicks the add record button and doesn't add
any information to the input fields and quits, the record save a blank (only
the username and date are stored in the record). How do I delete or not
prevent the user form saving the blank fields.

I can't use "default" simply because if the users doesn't want to enter
data, they should be able to quit without entering the data. Anyone have any
suggestions.
 
6

'69 Camaro

Hi.
If the user clicks the add record button and doesn't add
any information to the input fields and quits, the record save a blank (only
the username and date are stored in the record). How do I delete or not
prevent the user form saving the blank fields.

Try:

Me.Undo

This will prevent the new record from being saved. However, if this "new
record" has already been saved due to previous code or because the user has
moved off of the record and then moved back onto this "new record," any
changes since the last "Save" will be undone, but the record will still exist.

In this case, you must delete this record so that these "blanks" don't stay
in the table. Try something like:

Dim sqlStmt As String

sqlStmt = "DELETE * " & _
"FROM tblOrders " & _
"WHERE ID = " & Me!txtID.Value & ";"

CurrentDb().Execute sqlStmt, dbFailOnError
Me.Requery

.... where tblOrders is the name of the table that the form is bound to, ID
is the primary key, and txtID is the text box holding this value.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Top