Solved

Date Not working correctly

Posted on 2006-11-16
18
431 Views
Last Modified: 2008-02-01
Hi i have a script to create a date but it doesn't seem to work on a Server it crashes at the point......(MSSTDFMT)

Function Format(vExpression, sFormat)
        set fmt = CreateObject("MSSTDFMT.StdDataFormat")
        fmt.Format = sFormat
        set rs = CreateObject("ADODB.Recordset")
        rs.Fields.Append "fldExpression", 12 ' adVariant
        rs.Open
        rs.AddNew
        set rs("fldExpression").DataFormat = fmt
        rs("fldExpression").Value = vExpression
        Format = rs("fldExpression").Value
        rs.close: Set rs = Nothing: Set fmt = Nothing
End Function
strCDate = format(now(),"dd-mm-yyyy")
0
Comment
Question by:dion_p1
  • 7
  • 6
  • 5
18 Comments
 
LVL 29

Expert Comment

by:Nightman
ID: 17954334
What error are you getting?
0
 

Author Comment

by:dion_p1
ID: 17954351
ActiveX component cant create object......

How ever it works fin on my laptop?
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17954360
The MSSTDFMT.DLL is not registered on the machine
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 29

Expert Comment

by:Nightman
ID: 17954363
It should be located at C:\WINDOWS\system32\msstdfmt.dll
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17954370
have u registered MSSTDFMT.DLL on ur server?

>>Function Format(vExpression, sFormat)
also try to change your function name, since "Format" is an existing VBA function


0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17954376
little bit late i think ;-)
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17954377
The dll may not be on the machine - it is installed by visual studio 6.

You should be able to copy it to the C:\WINDOWS\system32 folder on the target machine and then register it
to register, run regsvr32 "C:\WINDOWS\system32\msstdfmt.dll" from the command prompt (start, run)
0
 

Author Comment

by:dion_p1
ID: 17954383
Is their not a way to generate a Current Date thats dependant on a solution such as this?
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17954389
Try removing your Format function and simply doing this:

strCDate = format(now(),"dd-mm-yyyy")

This is a standard (and default) VB function.
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17954445
It just occurred to me - are you using VBScript? If so, stick with your current solution (and copy and register the dll)
0
 

Author Comment

by:dion_p1
ID: 17954456
I get type mismatch at the part "Format(....)"
0
 

Author Comment

by:dion_p1
ID: 17954500
Is there any other way without having to register a dll?
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17954524
Not if you are using VBScript.

The alternative would be to write your own prodecure in VBS to handle this which would be more time consuming and probalby prone to errors.
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17954574
>>I get type mismatch at the part "Format(....)"

Give the entire line throwing error
0
 

Author Comment

by:dion_p1
ID: 17954594
Error: Type Mismatch: 'format
Code: 800A000D
Scource: Microsoft VBScript runtime error
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17954615
no no , i mean the line in ur code
0
 
LVL 14

Accepted Solution

by:
Shiju Sasidharan earned 500 total points
ID: 17954832
strCDate = Now()
strCDate = Day(strCDate) & "-" & Month(strCDate) & "-" & Year(strCDate)
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17954843
or you need to use  FormatDateTime Function

http://www.w3schools.com/vbscript/func_formatdatetime.asp
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

823 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