Unbound forms data entry

S

Senad

Hi All,

I have not used excel in some time, and I am looking for help:

I want to use unbound form to populate records in table.

Table: Date; Text1; text2; Memo

Any tips would be welcome.

Senad
 
O

Ofer Cohen

Try this code using a SaveButton on the Form

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurerntDb()
Set rs = db.OpenRecordset("TableName")
rs.AddNew
rs![Date] = Me.[Date]
rs![Text1] = Me.[Text1]
rs![Text2] = Me.[Text2]
rs![Memo] = Me.[Memo]
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing
=============================
You need to give your fields more meaningful names, also you better change
the fields name as [Date] that are resurved name in Access.

=============================
What about checking if the recrd already exist in the table

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurerntDb()
Set rs = db.OpenRecordset("Select * TableName Where FieldName =" &
Me.KeyField)
If Not rs.Eof Then
MsgBox "RecordExist"
Exit Sub
End If
rs.AddNew
rs![Date] = Me.[Date]
rs![Text1] = Me.[Text1]
rs![Text2] = Me.[Text2]
rs![Memo] = Me.[Memo]
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing
 
Top