#Error

  • Thread starter Thread starter Frank Dulk
  • Start date Start date
F

Frank Dulk

I have that it formulates in a control in the form, because when doesn't
have records appears #Error.

=DSoma("[pg_valorapagar]";"[QryDetalhePagamentoCliente]";"[pg_datapagamento]
is null")
 
Hi Frank:

Not sure what you are trying to say, but it seems that you get a DSum error
when the form is not populated with records. Why don't you place either in a
clickbutton or on your form's OnCurrent event the following code- it'll
check to see if there are records or not:

Dim dbs as database
Dim SQLStmt as string
Dim rst as recordset

Set dbs = CurrentDb()
SQLStmt = "SELECT YOURTABLE.* FROM YOURTABLE WHERE
([CurrentReccordACCT]= " & Me![ACCT] & ");"
Set rst = dbs.OpenRecordset(SQLStmt, dbOpenSnapshot)
On Error Resume Next
rst.MoveFirst
If rst.EOF Then
MsgBox "There are no records."
Else
[DSumField] = DSum("[pg_valorapagar]";"[QryDetalhePagamentoCliente",
[CurrentReccordACCT] = " & Me![ACCT])
End If

Alternatively, you can do this to prevent the #ERROR:

[DSumField] =
IIF(IsNull(DSum("[pg_valorapagar]";"[QryDetalhePagamentoCliente",
[CurrentReccordACCT] = " & Me![ACCT]),"",
DSum("[pg_valorapagar]";"[QryDetalhePagamentoCliente", [CurrentReccordACCT]
= " & Me![ACCT]))

Regards,
Al
 
Would not have as I outline that direct mistake in the origin of the control
where I use the function DSUM?


Al Borges said:
Hi Frank:

Not sure what you are trying to say, but it seems that you get a DSum error
when the form is not populated with records. Why don't you place either in a
clickbutton or on your form's OnCurrent event the following code- it'll
check to see if there are records or not:

Dim dbs as database
Dim SQLStmt as string
Dim rst as recordset

Set dbs = CurrentDb()
SQLStmt = "SELECT YOURTABLE.* FROM YOURTABLE WHERE
([CurrentReccordACCT]= " & Me![ACCT] & ");"
Set rst = dbs.OpenRecordset(SQLStmt, dbOpenSnapshot)
On Error Resume Next
rst.MoveFirst
If rst.EOF Then
MsgBox "There are no records."
Else
[DSumField] = DSum("[pg_valorapagar]";"[QryDetalhePagamentoCliente",
[CurrentReccordACCT] = " & Me![ACCT])
End If

Alternatively, you can do this to prevent the #ERROR:

[DSumField] =
IIF(IsNull(DSum("[pg_valorapagar]";"[QryDetalhePagamentoCliente",
[CurrentReccordACCT] = " & Me![ACCT]),"",
DSum("[pg_valorapagar]";"[QryDetalhePagamentoCliente", [CurrentReccordACCT]
= " & Me![ACCT]))

Regards,
Al

Frank Dulk said:
I have that it formulates in a control in the form, because when doesn't
have records appears #Error.
=DSoma("[pg_valorapagar]";"[QryDetalhePagamentoCliente]";"[pg_datapagamento]
is null")
 
Hi Frank:

You can use the second method right in your control, if you wish (i.e. the
one that uses the IIF...).

Regards,
Al

Frank Dulk said:
Would not have as I outline that direct mistake in the origin of the control
where I use the function DSUM?


Al Borges said:
Hi Frank:

Not sure what you are trying to say, but it seems that you get a DSum error
when the form is not populated with records. Why don't you place either
in
a
clickbutton or on your form's OnCurrent event the following code- it'll
check to see if there are records or not:

Dim dbs as database
Dim SQLStmt as string
Dim rst as recordset

Set dbs = CurrentDb()
SQLStmt = "SELECT YOURTABLE.* FROM YOURTABLE WHERE
([CurrentReccordACCT]= " & Me![ACCT] & ");"
Set rst = dbs.OpenRecordset(SQLStmt, dbOpenSnapshot)
On Error Resume Next
rst.MoveFirst
If rst.EOF Then
MsgBox "There are no records."
Else
[DSumField] = DSum("[pg_valorapagar]";"[QryDetalhePagamentoCliente",
[CurrentReccordACCT] = " & Me![ACCT])
End If

Alternatively, you can do this to prevent the #ERROR:

[DSumField] =
IIF(IsNull(DSum("[pg_valorapagar]";"[QryDetalhePagamentoCliente",
[CurrentReccordACCT] = " & Me![ACCT]),"",
DSum("[pg_valorapagar]";"[QryDetalhePagamentoCliente", [CurrentReccordACCT]
= " & Me![ACCT]))

Regards,
Al

Frank Dulk said:
I have that it formulates in a control in the form, because when doesn't
have records appears #Error.
=DSoma("[pg_valorapagar]";"[QryDetalhePagamentoCliente]";"[pg_datapagamento]
 
Back
Top