Re: How to manually save form data
am 18.10.2007 20:32:56 von OldPro
On Oct 18, 1:08 pm, "dufnobles via AccessMonster.com"
wrote:
> How can I manually save information entered on a form onto a table? The form
> information is derived from different tables. I want to inter the resulting
> information into another table. Please help. Thanks.
>
> --
> Message posted viahttp://www.accessmonster.com
With an unbound form, a Save button or a Save and Exit button is
typical. In its click event you would put something like the
following:
private sub cmdSave_click( )
dim db as database
dim rs as recordset
set db=currentdb( )
set rs=db.OpenRecordset("tblNew",dbOpenTable)
rs.addnew
rs!Name=txtName
rs!Address=txtAddress
rs!Phone = txtPhone
rs.update
rs.close
set rs=nothing
db.close
set db=nothing
End Sub
If the record is not new, but an edit of an existing record, then you
would use rs.edit instead of rs.addnew, and you would have to find the
record first. If it is type dbOpenTable, as is the example, then you
would use a seek statement. Otherwise, if it does not have an index
use a dbOpenDynaset instead of dbOpenTable and use a findfirst
statement.
rs.seek "=",txtName
if not rs.NoMatch then
...
or
rs.findfirst "Name=' " & txtName
if not rs.NoMatch then
...