Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1139
  • Last Modified:

undefined function: weekdayname

In MSAccess 2000 I try tu use the function "WeekdayName" in a query, but an error always occurs saying that this function is undefined. But I've found it in MSAccess VB Help. What must I do (or buy??) to use this function?

0
Bea
Asked:
Bea
  • 5
  • 4
  • 2
  • +2
1 Solution
 
WizmasterusCommented:
do a switch case using "Weekday". This function is going to return you 1,2,3 .... ,7 depending the day of the week.

vbSunday = 1    all the way to    vbSaturday = 7

You can use vb"NameOfDay" to do your case, it is nicer than 1, 2, 3 ...
0
 
WizmasterusCommented:
Visual Basic Scripting Edition  

WeekdayName Function
Returns a string indicating the specified day of the week.

WeekdayName(weekday, abbreviate, firstdayofweek)
Arguments
weekday
Required. The numeric designation for the day of the week. Numeric value of each day depends on setting of the firstdayofweek setting.
abbreviate
Optional. Boolean value that indicates if the weekday name is to be abbreviated. If omitted, the default is False, which means that the weekday name is not abbreviated.
firstdayofweek
Optional. Numeric value indicating the first day of the week. See Settings section for values.
Settings
The firstdayofweek argument can have the following values:

Constant Value Description
vbUseSystemDayOfWeek 0 Use National Language Support (NLS) API setting.
vbSunday 1 Sunday (default)
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday

Remarks
The following example uses the WeekDayName function to return the specified day:

Dim MyDate
MyDate = WeekDayName(6, True)   ' MyDate contains Fri.
0
 
WizmasterusCommented:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriversioninformation.asp


If you ever need to know the requirement of a function go there adn you should find it
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
BeaAuthor Commented:
Thanks Wizmasterus, I know how this function works, I've studied it in MSAccess VB help. The problem is that I cannot use it. Somehow MSAccess doesn't see it, it says "undefined function: WeekdayName.."

However, I can use Weekday without problems. If I can't solve the problem I will perhaps use the switch statement as you suggested.

Bea
0
 
WizmasterusCommented:
Shout me the code so i can see what is wrong
0
 
BeaAuthor Commented:
As I said it I try to use it in a query. The SQL statement is as follows:

SELECT WeekdayName(Weekday([InvoiceDate],0),True,2) AS WDN
FROM _Invoices
GROUP BY WeekdayName(Weekday([InvoiceDate],0),True,2);

after trying to launch this query I get the error: "Undefined function WeekdayName in expression".

Bea
0
 
shanesuebsahakarnCommented:
Whereabouts are you trying to use the function ?

Where you are trying to use it, do you have a field also called WeekDayName ?

An alternative is to use the Format function rather than a switch statement:
Format(Date(),"dddd")
will give you the full week day name.
0
 
WizmasterusCommented:
well the error is simple .... the problem is that whan it is executing the SQL statement, the WeekdayName and the other VB function are not define because there are not SQL statment...      

put a variable befor the statement wich is equal to your WeekdayName thing and try using it...
0
 
bob_onlineCommented:
From a code module, check the references menu item and see if any references are listed as missing.
0
 
BeaAuthor Commented:
Why I can't use WeekdatName in an SQL statement, while at the same time I can use for example Weekday function in SQL without problems? Maybe I should link something or make a reference or I don't know what?

Bea
0
 
BeaAuthor Commented:
I checked from a VB module Tools/References and I see a lot od unreferenced modules, I have only 5 of them checked as referenced:
VB for Applications
MSAccess 9.0 object library
OLE Automation
MS DAO 3.6 object library
MS Excel 3.0 object library
0
 
shanesuebsahakarnCommented:
It seems WeekDayName is a VBScript function and isn't available in VBA.

I have no idea which reference you would need to add in to have it available, I'm afraid.
0
 
nexusnationCommented:
Hi Bea,
This question has been abandoned and needs to be finalized (101 days since last comment).

   You can accept an answer, split the points, or get a refund. Go to
   http://www.cityofangels.com/Experts/Closing.htm for information and options.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

nexusnation
EE Cleanup Volunteer for Microsoft Access
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now