Need Help with adding a specific record or with DSUM

B

Bill Bisco

Hello all,

I have a continuous form that looks like this image
http://img518.imageshack.us/img518/474/screenshot042.png

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:

http://img147.imageshack.us/img147/1774/screenshot043.png

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:

Code:

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
.AddNew
.Fields("StationID") = strFieldName
.Fields("Process Name") = "New Process"
.Update
End With

Me.Parent.Refresh

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
image http://img299.imageshack.us/img299/8444/screenshot044.png

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.

Sincerely,
Bill
 
B

Bill Bisco

I have more eloquently stated my problems here
http://www.access-programmers.co.uk/forums/showthread.php?p=825441#post825441

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

Sincerely,
Bill
 

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