473,395 Members | 1,689 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,395 software developers and data experts.

“The expression you entered has a function containing the wrong # of arguments”

Hi,
Newbie here, still learning the basics. Thanks in advance for any help. I am working in VBA Access and feeding my code through a macro. I am getting the error message “The expression you entered has a function containing the wrong # of arguments.” I know this can be a pretty basic error but I can't find the problem. It's probably something silly. The strange thing is that the macro works fine and finishes making my table so I guess it has to do with some syntactical matter at the end (?)
Anyway, I appreciate any input. Code is below...
MK


Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Function ImportingDailyWarrantsFile()
  4.  
  5. Dim DateInput As String
  6. Dim WarrMsg As String
  7. Dim TableName As String
  8.  
  9. WarrMsg = "Pull warrants for which date [mmdd]?"
  10. DateInput = InputBox(Prompt:=WarrMsg, Title:="InputBox Title")
  11. TableName = "FT" & DateInput & "2013"
  12.  
  13. 'Import the file
  14. DoCmd.TransferText acImportDelim, "Regions Import Specification", TableName, "J:\Invest\Positive Pay\Download Files\FT" & DateInput & "2013.txt"
  15.  
  16. Call FormattingDailyWarrantsFile(TableName)
  17.  
  18. End Function    
  19.  
  20. Function FormattingDailyWarrantsFile(TableName)
  21.  
  22. FormatText = "SELECT CDbl(Left([Account],10)) AS [Account_No], CDbl(Mid([Account],11,10)) AS [Check_No], "
  23. FormatText = FormatText & "CDbl(Mid([Account],21,10))/100 AS [Amount], "
  24. FormatText = FormatText & "Cdate(Cstr(Mid([Account],33,2)) & '/' & Cstr(Mid([Account],35,2)) & '/' & Cstr(Mid([Account],31,2)))  AS [Date_Txt] "
  25. FormatText = FormatText & "INTO " & TableName & "F FROM " & TableName
  26.  
  27. DoCmd.RunSQL FormatText
  28.  
  29. End Function
Feb 21 '13 #1

✓ answered by zmbd

Insert at line 8
Expand|Select|Wrap|Line Numbers
  1. STOP
Insert at line 26:
Expand|Select|Wrap|Line Numbers
  1. debug.print FormatText
run your code
The VBA should stop and the VBE open at line 8 with a yellow highlight.
press [F8] function key to step thru the code.

Two things to note:
At what point does the error occur
If you get to line 26, press [F8]
then press <ctrl><g> to open the immediates window.
Check that the string posted in this window matches what you think it should.
You should also post that string back here (you can cut and paste :) within this window) ... click on the [CODE/] button in the format bar and past the string between the [code]..............[/code] tags.

7 3789
Seth Schrock
2,965 Expert 2GB
Try reading through Before Posting (VBA or SQL) Code, follow the directions in both A and B. This should tell us where the code is that is having the trouble if the error is on the VBA side.

I am working in VBA Access and feeding my code through a macro.
I'm not sure what you mean by "feeding my code through a macro." Does the macro call the VBA code or does the VBA code call the macro?
Feb 21 '13 #2
zmbd
5,501 Expert Mod 4TB
Insert at line 8
Expand|Select|Wrap|Line Numbers
  1. STOP
Insert at line 26:
Expand|Select|Wrap|Line Numbers
  1. debug.print FormatText
run your code
The VBA should stop and the VBE open at line 8 with a yellow highlight.
press [F8] function key to step thru the code.

Two things to note:
At what point does the error occur
If you get to line 26, press [F8]
then press <ctrl><g> to open the immediates window.
Check that the string posted in this window matches what you think it should.
You should also post that string back here (you can cut and paste :) within this window) ... click on the [CODE/] button in the format bar and past the string between the [code]..............[/code] tags.
Feb 21 '13 #3
Thanks all for your expert input. It was a silly rookie mistake and I found it. But all the suggestions helped me put it together...
Mar 3 '13 #4
zmbd
5,501 Expert Mod 4TB
Would you mind posting back what the solution you found was?
You'd be surprised at how often "Rookie" mistakes are made by us "experts" and having that solution here can help jog the old grey cells...
(point in fact, I was working with one of my union queries and just couldn't figure it out until I was reading thru stuff hereon Bytes and realized that it was a scope issue in my SQL!)
Mar 3 '13 #5
I was calling a second function both inside the first function and then also in the Macro. Its a matter of familiarizing myself with how the discrete chunks of code communicate with each other and pass information to each other. Also, physically clicking and running a macro seems like a whole different world than when functions are run straight from the code world. Just need some more experience. Thanks...
Mar 3 '13 #6
zmbd
5,501 Expert Mod 4TB
Well,
That is true that when you execute a VBA function or sub via the macro interface, the scope changes greatly.

I am still courious about how that string resolved...
Mar 3 '13 #7
the string was fine. the second function was called in the first function and the parameter passed effectively. Since I mistakenly had the second function as a RunSQL step in my macro (originally I thought that was the proper way to construct these things), that one did not have the proper parameter to work with.
Mar 3 '13 #8

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

Similar topics

0
by: belzibob | last post by:
I have an Access 2000 MDE that I can deploy via Wise 9.0 for Windows script successfully to 95/98, NT, 2000, XP, Xp/pro, and Me. This works fine in all environments on any number of pc's so I am...
2
by: Mikel | last post by:
I am trying to get around the problem "The expression you have entered is too complex" for a select query. (The example below is not the expression that is giving me headaches.) So I am thinking...
2
by: Michelle | last post by:
Hello all, I recently inherited a SQL 7.0 Server db accessed by a 2000 Access interface. When I try to open "Shipping Check Out" I am greeted with the following: The expression On Load you...
11
by: Neo | last post by:
Why the following code is compilable? The function abc() doesn't take any arguments, still i can call the function with arbitraty number of arguments. Even compiler doesn't show any warning. What...
7
by: VK | last post by:
I was getting this effect N times but each time I was in rush to just make it work, and later I coudn't recall anymore what was the original state I was working around. This time I nailed the...
4
by: MLH | last post by:
I have an error #2473. I don't think it is related to References. I rolled out an A97 mde file that runs on several machines - but gives me this error on one workstation??? Here's the error: ...
2
by: ilany | last post by:
Hi to all... Would greatly appreciate any suggestions. I'm trying to evaluate an expression during run-time that looks something like this: ...
2
by: Steven Hayes | last post by:
Thanks for any help I'm new at this. I have the following excel statement: =IF(B131="", "Input UFMIP", IF((B131-B133)<0, 0, IF(B131>0, B131-B133, 0))) I tried unsuccessfully to convert to...
1
by: Steven Hayes | last post by:
I am trying to convert this excel expression into an Access expression: =IF(OR(B79="",B62="", H7=""),"Required Fields Incomplete",IF(AND(F87<20000,OR(J87>P14, B87>P37)),"Yes, this is a HIGH COST...
2
by: Dave Smith | last post by:
Hi everyone again. I’m working on making my database roll with each month that changes. Below is what I have so far, and was hoping someone could help me with the rest. The error message I’m...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...

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.