?
Solved

undefined function: weekdayname

Posted on 2003-03-14
13
Medium Priority
?
1,109 Views
Last Modified: 2012-06-27
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
Comment
Question by:Bea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +2
13 Comments
 

Accepted Solution

by:
Wizmasterus earned 150 total points
ID: 8136404
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
 

Expert Comment

by:Wizmasterus
ID: 8136450
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
 

Expert Comment

by:Wizmasterus
ID: 8136473
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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:Bea
ID: 8136523
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
 

Expert Comment

by:Wizmasterus
ID: 8136609
Shout me the code so i can see what is wrong
0
 

Author Comment

by:Bea
ID: 8136686
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
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8136697
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
 

Expert Comment

by:Wizmasterus
ID: 8136733
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
 
LVL 5

Expert Comment

by:bob_online
ID: 8136750
From a code module, check the references menu item and see if any references are listed as missing.
0
 

Author Comment

by:Bea
ID: 8137083
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
 

Author Comment

by:Bea
ID: 8137110
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
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8137204
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
 
LVL 12

Expert Comment

by:nexusnation
ID: 8785717
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question