Dcount to create a new record in another table base on a record cr

M

Mail Merge Help

Hi

I have a Project form, I want the Apt10_ProjectStatusActivity to auto create
a record after a new record is created in the Project form. Below is my code.
but it didn't work.

Thanks in advance.

If DCount("[ProjectID]", "Apt10_ProjectStatusActivity", "[ProjectID]=" &
Me.ProjectID & " AND [ProjStatus]=1") = 0 Then


If Me.DataEntry = True Then
Set db = CurrentDb()
Set rst = db.OpenRecordset("Apt10_ProjectStatusActivity",
dbOpenDynaset)

With rst
.AddNew
.Fields("ProjStatusDate") = date '* see note below
.Fields("ProjectID") = Me.ProjectID '*
.Fields("ProjStatus") = 1 '*
.Update
End With
rst.Close
db.Close
End If
End If

'' * primary key in Apt10_ProjectStatusActivity table
 

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

Top