Need Help with adding a specific record or with DSUM

Bill Bisco

Active Member
Joined
Aug 8, 2007
Messages
446
Hello all,

I have a continuous form that looks like this

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 next form:

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

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
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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
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
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,934
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top