Dsoma using form as source

Asked

Viewed 25 times

-1

Halp!

I need a text field in my form to show the sum of a given field, where the form is the source using a criterion.

I can get Dsoma to run with the code below. However, as the source is the table, the result does not update as I filter my form.

=DSoma([valor_total];[t_registros];[t_cat_entradas_saidas_ID]=1)

I couldn’t figure out a way to reference the form in Dsoma field 2. It’s Possible?

Is there any way to bypass via VBA? Suddenly within the form filtering procedure?



Selection and filter section Seção de seleção e filtro



Text field Recipes Campo texto Receitas

  • I thought of using the procedure that filters the form to insert Dsoma in the text field with the filter criteria. However I do not know how to insert Dsoma in the text field control source via VBA.

1 answer

0

I was able to figure out how to solve the problem.

I fed my text field via VBA itself.

Dim txtReceitas AS Currency
Dim txtDespesas AS Currency

txtReceitas = Nz(DSum("[valor_total]", "t_registros", strWhere & "AND [t_cat_entradas_saidas_ID] = 1"), 0)
Me.txt_Receitas = txtReceitas

txtDespesas = Nz(DSum("[valor_total]", "t_registros", strWhere & "AND [t_cat_entradas_saidas_ID] = 2"), 0)
Me.txt_Despesas = txtDespesas

Super simple, but as I know little of VBA I fought to find the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.