Need Help with adding a specific record or with DSUM


Bill Bisco

Hello all,

I have a continuous form that looks like this image

It lists Processes that belong to this particular Station. The Query that
it's based off of uses Totals, and sums. As a result, it will only list
Processes that have have Elements to them. As you can see in the picture of
the next form:

If I add a Process, I must also add an element for it to appear so that the
user can edit it.

So I must do one of these 2

1. Make my Add Record Button, add an Element to the Process that I create
2. Change my query so that it will list Processes that have no Elements

For 1. My Code so far is:


Private Sub cmdAddRecord_Click()

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strTable As String
Dim strFieldName As String

strTable = "tblProcesses"
strFieldName = Me![tblProcesses.StationID]

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strTable)
With rst
.Fields("StationID") = strFieldName
.Fields("Process Name") = "New Process"
End With


End Sub

However, I do not know how to reference the record that I just created
because it does not appear on my form and is not selected so
rst.AddNew.Fields("Process ID") will not work to add an element.

For 2.

I have the following 3 items that would need to be converted to DSUM in this

I have tried:
TotalValueAdded: DSum(IIf([ValueAdded?]=True,[ElementTime],0))
DSum([ElementTime], "tblElements")

However, the format is wrong for the 1st equation, and the DSUM in the
second equation sums up all the Element Times from the table whereas I need
it to display only the sum of the Element Time for the specific process that
is being displayed.

Any help is greatly appreciated.




Bill Bisco

I have more eloquently stated my problems here

My main problem is this line of code

DoCmd.OpenTable ("tblProcesses")
DoCmd.GoToRecord acDataTable, "tblProcesses", acLast
strFieldName = Me![Process ID]
DoCmd.Close acTable, "tblProcesses", acSaveYes

I want to store what the [Process ID] field is for the current record in the
table. How can I do that? Me![Process ID] is not working.

Any help is appreciated


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

Similar Threads