megatronixs
Registered User.
- Local time
- Today, 23:36
- Joined
- Aug 17, 2012
- Messages
- 719
Hi all,
I have some code to get the sum results from a table that I want to pass as a variable in the rest of the code.
I have the trouble that when there is a 0 because the query can't sum null values.
I also used this in the last part:
This Error 94 invalid use of Null is really hard to crack and I tried so many combinations that I'm lost.
greetings.
I have some code to get the sum results from a table that I want to pass as a variable in the rest of the code.
I have the trouble that when there is a 0 because the query can't sum null values.
Code:
'run query to get the results to sum up later
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_profile_1_1"
DoCmd.SetWarnings True
Set rsProfile2 = CurrentDb.OpenRecordset("tbl_profile_1_1")
'Open connection to current Access database
Set db = CurrentDb()
'Create SQL statement to retrieve value from tbl_profile_1_1 table
LSQL = "SELECT Sum(tbl_profile_1_1.CountOfORDERING_INST_NAME) AS SumOfCountOfORDERING_INST_NAME FROM tbl_profile_1_1;"
Set Lrs = db.OpenRecordset(LSQL)
LGST = ""
'Retrieve value if data is found
If Not IsNull(Lrs) Then
LGST = Lrs("SumOfCountOfORDERING_INST_NAME")
End If
I also used this in the last part:
Code:
If Not Lrs.RecordCount > 0 Then
LGST = Lrs("SumOfCountOfORDERING_INST_NAME")
End If
This Error 94 invalid use of Null is really hard to crack and I tried so many combinations that I'm lost.
greetings.