Roger:

In between the rs.Addnew and the rs.Update, you have to MOVE some data into
the fields in rs.  AddNew adds a new, blank record.  Update saves the
record, but in between you have to put something INTO the record.  So move
some date from the fields on the form (text boxes or whatever) to the fields
in rs.

Since you're using a disconnected recordset (rs), it has no way of knowing
that there's data on the form, so you have to move it there field by field.

rs.AddNew
rs!Lastname = me.txtLastname   'something like this
rs!SocSecNo = me.txtSSN
rs.Update

Hope that helps.

  -----Original Message-----
  From: [email protected]
[mailto:[EMAIL PROTECTED] Behalf Of Roger Shuttleworth
  Sent: Friday, April 20, 2007 11:49 AM
  To: [email protected]
  Subject: [Access VBA Central] Novice question regarding recordsets and
records (ADO)


  Hello All

  Please forgive the novice question; I am just beginning Access VBA,
  though I have done a fair amount of Word VBA in the past.

  I'm using an ADO disconnected recordset derived from a single table. I
  have a form with an Add New button, and the onClick event fires an
  AddRecord sub that is basically:
  Clear the fields on the form
  rs.AddNew
  rs.Update

  If I understand correctly, the first line clears the field, and the
  second adds a new, blank record to the local recordset. Does the
  Update method update the blank record with the values on the form
  (which are blank)?

  I also have a button that reopens the connection, saves the changes to
  the database, and closes the connection.

  Problem: I seem to end up with (i) blank rows in the database, or (ii)
  an error message saying that the record must have at least one field
  with a value. Not quite sure what scenario produces each, but I've
  certainly seen both.

  Could someone please explain to me how this works? And how I can
  prevent it happening?

  I told you it was a dumb question...

  Thanks.

  Roger Shuttleworth
  London, Canada



  


[Non-text portions of this message have been removed]

Reply via email to