Well the only way round it I can think of is creating and populating the table, then adding a field using ADOX, then using VBA in Excel over ADO to loop through each line of the dataset. Then I can run as many IIFs as I want, and plug the calculated values back into the DB.
If anyone has a more elegant solution for use in the future, I'd be interested to hear it. :)
User Profile
Collapse
-
Thanks for your input, that's another way of looking at the logic, however, it doesn't solve my problem, as I still get the error
"Run-time error '-2147217900 (80040e14)':
Undefined function 'functionName' in expression."
I wanted to check that I was implementing the custom function correctly (inside a module), and I came across this:
http://www.thescripts.com/forum/thread124351.html
"Basically,...Leave a comment:
-
Good point, i'll switch to ampersande. Out of interest, I changed to ampersandes in this code and tested again, but no dice. ;)Leave a comment:
-
Arbitrary decision, didn't think there was any difference between the two.Leave a comment:
-
Unfortunately not, it contains confidential information.
Any help is of course appreciated. :)Leave a comment:
-
I'm using it in SQL, not VBA, as in your case, MTB.
A simplified version:
...Code:Public Sub MakeCallTable() Dim adoConnection As ADODB.Connection Dim adoxCatalog As ADOX.Catalog Dim cmdQueryMake As ADODB.Command Dim recSet As ADODB.Recordset Dim adoxProc As ADOX.Procedure Dim adoxTable As ADOX.Table Dim strYear As String Dim strDatabasePathLeave a comment:
-
Thankyou for your reply.
I've created a MyFunctions module containing a public function containing the relevant logic. This also works fine when called directly from the Access GUI, no problems there.
However, once again, a problem crops up when trying to call this function over ADO from VBA. The error message states "Undefined function 'Blah' in espression."
This is when constructing the SQL query...Leave a comment:
-
Apologies, found http://www.thescripts. com/forum/thread192015.ht ml just after I posted.
And I quote
"IIF is a VBA function which means that when this query is run in
Access it goes through th expression service in order to evaluate the
function, this doesn't happen when run through DAO."
If this is also true for ADO, that might explain it. So, is there no other solution other than rewriting my...Leave a comment:
-
IIF() logic failure over ADO
I'm having a problem when trying to pull data out of an Access database to plug into an excel spreadsheet with VBA.
It's all working fine, apart from a nested IFF() statement, which is working fine when I run it manually in Access, but when I try to run it from VBA over ADO, it evaluates as if all the expressions are false (not the case).
I tried creating the query from VBA using ADOX to make sure the syntax was correct,...
No activity results to display
Show More
Leave a comment: