Solved

Date Not working correctly

Posted on 2006-11-16
18
429 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Window placement 17 74
SSRS expression Issue finding a string 10 65
Modifying Conditional Format from VBA code 3 48
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 45
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

919 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now