473,513 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why will Month() work, but MonthName() won't work in my textbox?

Seth Schrock
2,965 Recognized Expert Specialist
I've got a textbox on a report that I'm using to pull the month and year from two textboxes on a form. The following code works in the data source of the textbox:
Expand|Select|Wrap|Line Numbers
  1. ="Billing Period: " 
  2. & Month([Forms]![frmCustomer]![txtStartDate]) 
  3. & " " 
  4. & Year([Forms]![frmCustomer]![txtStartDate]) 
  5. & " - " 
  6. & Month([Forms]![frmCustomer]![txtEndDate]) 
  7. & " " 
  8. & Year([Forms]![frmCustomer]![txtEndDate])
However, I would like to make it so that I get the name of the month instead of the number. So I tried the following:

Expand|Select|Wrap|Line Numbers
  1. ="Billing Period: " 
  2. & MonthName([Forms]![frmCustomer]![txtStartDate]) 
  3. & " " 
  4. & Year([Forms]![frmCustomer]![txtStartDate]) 
  5. & " - " 
  6. & MonthName([Forms]![frmCustomer]![txtEndDate]) 
  7. & " " 
  8. & Year([Forms]![frmCustomer]![txtEndDate])
When I preview the report, however, it returns #Func!. Is the MonthName() function not available in this situation? I don't get any syntax errors while in design view of the report. I even tried adding the ,False to the MonthName() function in case it wanted me to explicitly declare the default, but that didn't change anything.
Nov 4 '11 #1
2 1867
ADezii
8,834 Recognized Expert Expert
The MonthName() Function does not accept a Date as an Argument, but a Numeric Value between 1 and 12, as in:
Expand|Select|Wrap|Line Numbers
  1. Debug.Print MonthName(1)  'returns January
  2. Debug.Print MonthName(10) 'returns October
  3. Debug.Print MonthName(4)  'returns April
  4. Debug.Print MonthName(8)  'returns August
  5. Debug.Print MonthName(6)  'returns June
  6.  
What will work is:
Expand|Select|Wrap|Line Numbers
  1. 'Returns November
  2. Debug.Print MonthName(Month(#11/5/2011#))
  3.  
Nov 4 '11 #2
Seth Schrock
2,965 Recognized Expert Specialist
Okay, that makes sense. Thanks.
Nov 4 '11 #3

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

Similar topics

3
6343
by: Oliver Spiesshofer | last post by:
Hi, I have a script that calls an fopen() on an external URL. I can run the script from the server as an url fine. When however the script should be run from crontab, it does not work. I get ...
5
8008
by: Catherine | last post by:
I am having a problem viewing asp pages on iis version 5.1 xp pro. HTML pages are viewable on http://localhost but .asp pages are not. I have created a test program called timetest.asp with the...
19
2020
by: Allen Thompson | last post by:
sorry for the simple question, haven't done this in a while. when I use the following script it keeps displaying the value of "x" like a string. for example, if I type the number 7 in the prompt,...
0
1960
by: Sebastian Sosna | last post by:
Hi there! iam trying a code snippet from MSDN heres the link : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/netds/creating_groups.asp ive tried the code but it...
7
4456
by: Christine | last post by:
My code has a split function that should split the text file of numbers. I've run this in previous programs as it is here and it worked, but now it wont work for some reason and returns...
1
1389
by: Gary | last post by:
I have the following in my web.config.... <customErrors mode="RemoteOnly" defaultRedirect="Applicationerror.aspx"/> but, my error page does not display. Instead a 'Runtime Error' page...
14
3059
by: squash | last post by:
The following code works fine in Firefox/Netscape but wont work in IE. I suspect the problem is with one of these two simple functions. If there is no obvious error Ill paste the entire code. ...
8
1843
by: Mark12345 | last post by:
Hi folks, thanks for looking. I have a database that takes down order details. Each customer has there own priceid in the price table. the errors that I get say enter parameter value for:...
2
2574
by: jcollins1991 | last post by:
im trying to make a program thats supposed to check whether 2 strings are anagrams of each other (anagram = same letters in both strings, but in different orders... "cool as wet art" , and "cs at...
2
1719
by: Admiral | last post by:
Hi, Anyone knows how this works? I have made a textbox called Editbox1 and 10 buttons. b0, b1, b2 etc. What i want to do is when i press a button, b1 for example, a number 1 appears into...
0
7267
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
7175
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
7391
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
7553
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...
1
7120
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
7542
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...
0
5697
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,...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1609
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.