Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 28th, 2007, 03:25 PM
Registered User
 
Join Date: Sep 2007
Location: Cambridge, MA, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Malformed GUID Error runtime 3075

Hello everyone,

I am writing a database for my company. Right now my access file can compare 2 different indices and graph them. My boss recently asked me to put a XIRR function in the access database. However, as my search suggests that Access does not have the XIRR function from excel. So I had to write code to import the function and use it in Access. However, I keep getting malformed GUID error. I believe this is about how I enter the Date.
The code is like this:
Option Compare Database

Private Sub Command0_Click()

Dim db As DAO.Database
Dim rs As DAO.Recordset, strsql$

Dim dIRRresult As Double

Dim dNPVResult As Double

Dim lDiscountRate As Double

Dim objExcel As Excel.Application

Dim ArrDates() As Long

Dim ArrAmounts() As Long

Dim lRecordCount As Long

Dim intCounter As Long


' Initialise the Excel application and register the Analysis toolpak file

Set objExcel = New Excel.Application


objExcel.RegisterXLL objExcel.Application.LibraryPath & "\ANALYSIS\ANALYS32.XLL"


'Initialise the database and the recordset

Set db = CurrentDb

strsql = "SELECT Dowjones.Index, " & " Dowjones.Date, " & " Dowjones.Close " & " FROM [Dowjones]" & "WHERE (Dowjones.Index={'" & [Forms]![sear12X]![tindex] & "'}) AND " & " ([Dowjones.Date]<{'" & [Forms]![sear12X]![tstart] & "'}) AND " & " ([Dowjones.Date]>{'" & [Forms]![sear12X]![tend] & "'})"






Set rs = db.OpenRecordset(strsql, dbOpenDynaset)

lRecordCount = rs.RecordCount


'read the values into the array only of there is more than one value in the cash flow stream. Otherwise the 'functions would not work anyway.


If lRecordCount > 1 Then



'Initialize the arrays which hold the period and cashflow numbers using the recordcount of the recordset

ReDim ArrDates(1 To lRecordCount) As Long

ReDim ArrAmounts(1 To lRecordCount) As Long

'Read the period and cashflow values from the recordset and put them in the arrays.

For intCounter = 1 To lRecordCount

ArrDates(intCounter) = CLng(CDate(rs!Period))

ArrAmounts(intCounter) = rs!NET_AMOUNT

rs.MoveNext

Next intCounter

'Read the Discount rate (for calculating NPV) from wherever you store it.

lDiscountRate = IIf(IsNull(DLookup("Discount_rate", "TABLE", "COLUMN =" & Value)), 0.15, DLookup("Discount_rate", " TABLE ", " COLUMN =" & Value))


'This is the actual call to the XIRR function.

dIRRresult = IIf(IsError(objExcel.Run("XIRR", ArrAmounts, ArrDates)), 0, objExcel.Run("XIRR", ArrAmounts, ArrDates))

dNPVResult = IIf(IsError(objExcel.Run("XNPV", lDiscountRate, ArrAmounts, ArrDates)), 0, objExcel.Run("XNPV", lDiscountRate, ArrAmounts, ArrDates))

End If

rsAssets.MoveNext




objExcel.Quit

Set objExcel = Nothing

End Sub


I got some parts of the code from somewhere on the net. Well i am not sure what is exactly wrong with the code. I believe there is a problem about how I enter the date in the form(sear12X) which is associated with this code. Also I may have messed when converted the SQL query to VBA. If you could help me I will be more than happy. Also as a note, I am not going to have the NPV function. It was just in the code when I copied it. ANyway I dont believe that it is causing the problem. Thanks


Reply With Quote
  #2 (permalink)  
Old October 1st, 2007, 08:21 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

IRR is available locally in Access in an array. Let me know if you want help with that.



mmcdonal
Reply With Quote
  #3 (permalink)  
Old October 1st, 2007, 08:27 AM
Registered User
 
Join Date: Sep 2007
Location: Cambridge, MA, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I know there is IRR but I need to use the XIRR function. Does anybody have an idea about that?

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hi i got runtime error 13 Type Mismatch error sriharsha345 Access VBA 2 February 21st, 2008 09:30 AM
runtime error dhoward VB.NET 2002/2003 Basics 2 November 1st, 2007 03:30 PM
MS Access ComboBox GUID Error mp01 BOOK: Beginning VB.NET Databases 13 November 24th, 2006 04:12 PM
mysterious error runtime error '451' coyotworks Excel VBA 1 May 12th, 2006 03:57 PM
Guid Error in listview click event Jimson BOOK: Beginning VB.NET Databases 9 February 16th, 2006 01:57 PM



All times are GMT -4. The time now is 07:23 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.