Unbound forms data entry

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top