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

Argument not optional error in VB module

Hi

I have an after update event on a field on my people form.

When i try to debug the code i get an "Argument not optional" error in
relation to the IIf statement.

I used the same code in an update query and it worked perfectly.

PE_Initials = (Left([PE_First_Name], 1) & IIf(InStr(1, [PE_First_Name],
" ") <> 0, Mid([PE_First_Name], InStr(1, [PE_First_Name], " "), 2)))

Can anyone tell me why this doesn't work in the code module.

Thanks

Gillian

Apr 24 '06 #1
2 4332
"Gilz" <gd*****@tlpsystems.co.uk> wrote in
news:11*********************@i40g2000cwc.googlegro ups.com:
Hi

I have an after update event on a field on my people form.

When i try to debug the code i get an "Argument not optional"
error in relation to the IIf statement.

I used the same code in an update query and it worked
perfectly.
You didn't. :-) You think you did, but you copied it wrong.
PE_Initials = (Left([PE_First_Name], 1) & IIf(InStr(1,
[PE_First_Name], " ") <> 0, Mid([PE_First_Name], InStr(1,
[PE_First_Name], " "), 2)))

Can anyone tell me why this doesn't work in the code module.

Thanks

Gillian

PE_Initials = (Left([PE_First_Name], 1) _
& IIf(InStr(1, [PE_First_Name], " ") <> 0, _
Mid([PE_First_Name], _

above is good. Below is nonsense to Access

InStr(1, [PE_First_Name], " "), 2)))

--
Bob Quintal

PA is y I've altered my email address.
Apr 24 '06 #2
Hi

Thanks for that Bob but i have double checked the query and that is the
correct string and it works perfectly to give me the second initial is
the field person name has two words in the query.

I am running access 2000 but the code definately works in my update
query.

Gillian

Apr 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alan Little | last post by:
Is it possible to make a by-reference argument optional in a UDF? When I try to assign it a default value in the definition, I get a parse error, "unexpected '='". PHP itself has optional by-ref...
6
by: Steven Bethard | last post by:
I was wondering if there's any plans to add a "key" argument to max (and min) like was done for sort(ed)? I fairly often run into a situation where I have something like: counts = {} for item...
0
by: Christopher Li | last post by:
I am surprised to find out the mmap module in python always mmap from offset 0. So I just hack up some patch to allow it accept offset arguments. So here it is. Chris Add optional offset...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
0
by: Bobbak | last post by:
Hello All, I could really use some help with this bit of code I am working on, every time I come to execute it I get an error that says "Compile Error: Argument not optional". Now I am using...
42
by: WindAndWaves | last post by:
Dear All Can you tell me why you use a class module??? Thank you Nicolaas ---
13
by: William Ryan | last post by:
I just picked up a copy of John Robbins' debugging book and started to look at disassembled code. Anyway, I hate optional Parameters in VB, but I was checking them out to see what IL is created. ...
4
by: Patient Guy | last post by:
Does anyone have any coding rules they follow when doing argument checking? When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw...
0
by: James Mills | last post by:
On Fri, Oct 31, 2008 at 8:49 AM, mark floyd <emfloyd2@gmail.comwrote: Mark, this is correct behavior. You have 3 positional arguments in the function definition. You _must_ aupply _all_ 3 of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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...

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.