473,655 Members | 3,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Expression has wrong number of arguments

4 New Member
Please help out a newbie. I've copied a complicated query and am trying to modify it for mailing labels. First, last name and primary address are the fields. Primary address would be either a home or work address. The prior query was made to list primary phone number of which the number was just one field (ex: 213-300-0000). However, the primary address would include street address, city, state and zip for a total of 4 fields. I receive an error after I add the city, state and zip fields after the street address field in the expression.

Error: The expression you entered has a function containing the wrong number of arguments.

Here is the code I am using:
Primary Address: IIf([txtPrimaryAddr]='home',[txtAddress],[txtCity],[txtState],[txtZip],IIf([txtPrimaryAddr]='business',[txtWorkAddr],[txtWorkCity],[txtWorkState],[txtWorkZip])

Any advice?

Thanks in advance.
Nov 19 '07 #1
6 20511
akirekab
47 New Member
Please help out a newbie. I've copied a complicated query and am trying to modify it for mailing labels. First, last name and primary address are the fields. Primary address would be either a home or work address. The prior query was made to list primary phone number of which the number was just one field (ex: 213-300-0000). However, the primary address would include street address, city, state and zip for a total of 4 fields. I receive an error after I add the city, state and zip fields after the street address field in the expression.

Error: The expression you entered has a function containing the wrong number of arguments.

Here is the code I am using:
Primary Address: IIf([txtPrimaryAddr]='home',
[txtAddress],[txtCity],[txtState],[txtZip],IIf([txtPrimaryAddr]='business',[txtWorkAddr],[txtWorkCity],[txtWorkState],[txtWorkZip])

Any advice?

Thanks in advance.
I am not an expert, but First I would avoid using IIF in VBA, as per a note elsewhere in this forum. I am answereing since I dont see anyone else trying this one.
That being said, IIf takes and expression and if true, returns the first argument, after the expression, and if false returns the second argument. Since a comma "," is an integral part of the function, I am thinking you can only have two. Like this:

IIf Function Example
This example uses the IIf function to evaluate the TestMe parameter of the CheckIt procedure and returns the word "Large" if the amount is greater than 1000; otherwise, it returns the word "Small".

Function CheckIt (TestMe As Integer)
CheckIt = IIf(TestMe > 1000, "Large", "Small")
End Function

I think I would use a plain If, then,else statement to resolve your issue.
Like:
[code]
If "txtPrimary Addr = Home then
[txtAddress],[txtCity],[txtState],[txtZip]
else if ([txtPrimaryAddr]='business') then
[txtAddress],[txtCity],[txtState],[txtZip]
End If
{/CODE]

My syntax my be a little off, and I am not sure how your differentiating between what txtAddress is home and business, but hopefully some of this is helpful.
Nov 20 '07 #2
FishVal
2,653 Recognized Expert Specialist
IIf() function is expected to have 3 arguments.
Fields [txtAddress],[txtCity],[txtState],[txtZip] separated by commas are recognised as 4 arguments.
Iif you want to merge them use concatenation operator "&".

Regards,
Fish
Nov 20 '07 #3
tinareed
4 New Member
It worked, Fish, thank you both so much for answering...Now on to formatting the mailing labels.

Best,
TR
Nov 20 '07 #4
tinareed
4 New Member
Another question related to this query:

I used the mailing label wizard for the report using this query.
1. The first and last name appear correctly on the first line of the label. However, there is no space between the 2 fields.
2. The primary address field consists of street address, city, state and zip. They all show up on the 2nd and 3rd lines of the labels with no line or space breaks.

How can I correct these formatting problems? Is there code I can insert in the query expression? Thanks a lot, I've looked in my manuals and do not see this situation where the address is combined into one field because of the primary address expression.
Nov 28 '07 #5
FishVal
2,653 Recognized Expert Specialist
Concatenate the fields with spaces and/ or separators.
fld1 & " " & fld2 & ", " & fld3

Regards,
Fish
Nov 28 '07 #6
tinareed
4 New Member
I found the answer to my questions. I was looking in the wrong place. Thanks for considering this if you had read it. :-)
Nov 28 '07 #7

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

Similar topics

23
3220
by: Paul Rubin | last post by:
OK, I want to scan a file for lines matching a certain regexp. I'd like to use an assignment expression, like for line in file: if (g := re.match(pat, line)): croggle(g.group(1)) Since there are no assignment expressions in Python, I have to use a temp var. That's a little more messy, but bearable:
2
13256
by: Pial | last post by:
Hi : I am using Asp.Net, C#, Oracle . I am trying to execute this Stored Procedure, and it gives me an error "Error Message: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'GET_CITY_DATA' ORA-06550: line 1, column 7: PL/SQL: Statement ignored " Thanks in Advance
5
2826
by: titan0111 | last post by:
#include<iostream> #include<iomanip> #include<cstring> #include<fstream> using namespace std; class snowfall { private: int ft;
1
2361
by: PengYu.UT | last post by:
Hi, I read Klaus Kreft & Angelika Langer's C++ Expression Templates: An Introduction to the Principles of Expression Templates at http://www.angelikalanger.com/Articles/Cuj/ExpressionTemplates/ExpressionTemplates.htm It provide an express template for only one argument (see Listing 19 and so on), which can be used to do numerical integral. I'm wondering how to generalize it to handle multiple arguments.
2
2050
by: Jan Engelhardt | last post by:
Hi, I was told that order of evaluation is unspecified for functions, i.e. int f = 0; print_results(modify(&f), modify(&f), modify(&f)); where i.e. modify() increases f by one. In my case w/gcc, it was evaluated from right-to-left (gcc does a nice stack optimization). Not what I expected though.
15
13066
by: XZ | last post by:
Hi everyone, this is really confusing to me: #include <stdio.h> main(int argc, char **argv) { printf("argv = %f\n",(double)atof(argv)); printf("argv = %d\n\n",atoi(argv)); } $ a.out a argv = 97.000000
7
12940
by: Tizzah | last post by:
What is wrong with that? regex = /^(http|https):\/\/+({1}+)*\.{2,5}(({1,5})?\/.*)?$/ if(field.hpage.value != regex.test(field.hpage.value)){ alert("Bad Homepage") field.hpage.focus() field.hpage.select() return false
42
3428
by: Holger | last post by:
Hi guys Tried searching for a solution to this, but the error message is so generic, that I could not get any meaningfull results. Anyways - errormessage: ---------------------------------------------------- TypeError: addFile() takes exactly 1 argument (2 given) ----------------------------------------------------
17
17356
by: Peter Tenk | last post by:
Hi I've never really worked with VBScript - I'm an old-fashioned HTML guy - but I thought I'd have a go because I wanted to do something REALLY SIMPLE in my Access 2000 database. This is a plea for help, days later, having trawled the Internet repeatedly and experimented as much as I dare looking for anything that will work. I have a form called Communications (I now know it shoulda been frm_Communications!). In it there is a combo box...
0
8380
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8598
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7310
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1598
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.