473,287 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

#error using Dsum

222 100+
Hello

I have a subform base on query. I used a textbox with a control source =

Expand|Select|Wrap|Line Numbers
  1. =nz(DCount("ref_ID","checklist","[profession_id]=" & [ProfessionId] & "and" & "[passed]= " & True & " and" & "[blockid]='" & [Forms]![block_id]![block_id] & "'  "),0)
Each time we add a new record to the subform it works properly unless the last record (I mean the newrecord that it doesn't containt any values)It is #ERROR.
Actually for me it is not a problem but for my boss it is :S.

He asked me to change it to 0 , "" or anything else then #error.

Any Idea how to do that ? NZ function is not working


CHEERS;

WASSIM S DACCACHE
Aug 12 '08 #1
2 2179
Stewart Ross
2,545 Expert Mod 2GB
Hi Wassim. The null values that cause the error relate to the parameters passed to the DCount function itself, not to the result of the DCount, so Nz applied to the DCount result does not help.

I suggest you use an IIF to test one of the underlying field values and if the field is null return a 0 in place of the DCount:

Expand|Select|Wrap|Line Numbers
  1. =IIF(IsNull([ProfessionID]), 0, DCount("ref_ID","checklist","[profession_id] = " & [ProfessionId] & " AND [passed] = " & True & " AND [blockid] = '" & [Forms]![block_id]![block_id] & "'"))
I have adjusted the spacing of the arguments slightly - you were leaving out spaces between some operators and concatenating others without really needing to.

-Stewart
Aug 12 '08 #2
wassimdaccache
222 100+
Hi Wassim. The null values that cause the error relate to the parameters passed to the DCount function itself, not to the result of the DCount, so Nz applied to the DCount result does not help.

I suggest you use an IIF to test one of the underlying field values and if the field is null return a 0 in place of the DCount:

Expand|Select|Wrap|Line Numbers
  1. =IIF(IsNull([ProfessionID]), 0, DCount("ref_ID","checklist","[profession_id] = " & [ProfessionId] & " AND [passed] = " & True & " AND [blockid] = '" & [Forms]![block_id]![block_id] & "'"))
I have adjusted the spacing of the arguments slightly - you were leaving out spaces between some operators and concatenating others without really needing to.

-Stewart
I appreciate your Kind help for me. It is working properly with the criteria optimized

Best regards,

WASSIM S DACCACHE
Aug 12 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: rwalker | last post by:
Error number 429 - COM object with CLSID {000209F0-0000-0000-C000-000000000046} is either not valid or not registered. Intermittent occurance of this error. Using Word.Global to run word macro...
3
by: Andrew Luke | last post by:
Hi all you C++ guru's! I'm 'very, very' new to C++ and I'm having a little trouble configuring my VS environment I think - when I try and compile some sample code I'm getting the following...
0
by: seanseaghan | last post by:
New to this group, so greetings all! I am trying to develop query syntax in Access 2000 to accomplish the following: Imagine you are in an accounting dept. and you are working on a...
1
by: Eric | last post by:
Using the 1.1 framework. We are using a newly created instance of a RichTextBox Class in our server code to manipulate RTF that is stored in the database. To clarify, we are not using or...
1
by: ns2k | last post by:
I add reference office.dll and Microsoft Office Excel Component to my project and use : --------------------------------------- Dim App As Excel.Application, BarName as String ... Dim Bar As...
11
by: Frankie | last post by:
Hello: New user here...first post to group. I'm getting an SQL syntax error when I try to run the following query: $query = sprintf("SELECT itemNumber, entryDate, modifyDate, thumbnailURL,...
2
by: ckpoll2 | last post by:
Hello, I'm trying to build a text box in a form that will add hours for a two week period. I have created a query to return the hours in the two week range, but the same name and hour type will...
0
by: sa6113 | last post by:
I am using this code to connect to a windows machine using paramiko, I have installed sshd on the machine and it works properly: sock.connect((hostname, port)) t = paramiko.Transport(sock)...
5
by: munkee | last post by:
Right a bit of a headache here. I basically wanted to create a cumulative total of a percentage through a query. To put that in a more physical way: NCTYPE Freq cpercent x 2 ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.