Solved

InstrRev function not defined...

Posted on 2006-06-21
15
498 Views
Last Modified: 2011-09-20
If I input the query below directly into Access, it works - however if I try to run it inside my vb/vbs app, it fails with the error in the subject...(using ado)


 .Execute "CREATE PROC qryServerMemoryTotals AS SELECT ServerName AS [Server Name], Trim(Mid(MemID,InstrRev(MemID,'e') +1)) AS Slot, cInt(MemSize) AS [Size] FROM tblServer_RAMData WHERE MemSize <> '0' ORDER BY ServerName UNION ALL SELECT Trim(ServerName) & ' Total:' AS [Server Name], '', SUM(cInt(MemSize)) AS [Size] FROM tblServer_RAMData WHERE MemSize <> '0' GROUP BY Trim(ServerName) & ' Total:' ORDER BY [Server Name]"
0
Comment
Question by:sirbounty
  • 8
  • 6
15 Comments
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 500 total points
ID: 16951698
Does this work?

.Execute "CREATE PROC qryServerMemoryTotals AS SELECT ServerName AS [Server Name], Trim(Mid(MemID,Len(MemId)-Instr(MemID,'e')-1)) AS Slot, cInt(MemSize) AS [Size] FROM tblServer_RAMData WHERE MemSize <> '0' ORDER BY ServerName UNION ALL SELECT Trim(ServerName) & ' Total:' AS [Server Name], '', SUM(cInt(MemSize)) AS [Size] FROM tblServer_RAMData WHERE MemSize <> '0' GROUP BY Trim(ServerName) & ' Total:' ORDER BY [Server Name]"

BFN,

fp.
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16951703
PS. Which version of MS-Access are you using?
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16951711
"InstrRev" was only introduced in MS-Office 2000 (and Visual Basic 6).
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 67

Author Comment

by:sirbounty
ID: 16951796
Using Access 2003 - I believe it's an ADO problem more than likely (as I mentioned it works within Access).
Will try out your post and let you know...
0
 
LVL 9

Expert Comment

by:dancebert
ID: 16953259
Access string functions are available to SQL executed in Access.  When you run in VB, the Access string functions don't exist.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 17047555
dancebert - missed the notif for your post - but could you elaborate why this is not available in ADO?
0
 
LVL 67

Author Comment

by:sirbounty
ID: 17080966
fp - sorry for the delay.
I've input your first post and the process runs tomorrow morning at 5am EDT.  I'll let you know soon after.
Thanx!
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 17081605
OK, Thanks for your update.

However, I would advise running any SQL statement in a test environment prior to deployment into a live production environment...
0
 
LVL 67

Author Comment

by:sirbounty
ID: 17081650
I don't see any way this could cause problems...
The database is created dynamically each week.  The query either works (or has been in the past - not).
It's not an update query - so what would be the reason for caution?
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 17081724
Because I'm a cautious person!

Why would you run any query in a live environment that had not been tested previously?

What if it took 4 hours to complete?

I wasn't aware the database was created dynamically, so it is not a huge problem if the query failed to be created, or to execute, but surely it wouldn't take long to run now to stop a failure before it happened.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 17098929
Bah!  Forgot to compile it... (don't laugh!).
I'm rerunning it now though - even though it's outside of the normal weekly run, I should still know something within the hour...
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 17099001
Is a smile allowed aloud? :)
0
 
LVL 67

Author Comment

by:sirbounty
ID: 17099165
Sure - you can smile... heh heh...it was kind of funny...

Well, it runs - but it's not producing the output as expected.
I get

[Server Name]   |  [Slot]    |  [Size]

All slots are empty - everything else is populated correctly.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 17099201
Sample table:

ServerName  |  MemID  |  MemSize  |
<MyServer>  |  Memory Device 0  |  1,024
<MyServer>  |  Memory Device 1  |  1,024
<MyServer>  |  Memory Device 2  |  1,024

Since I'm creating these fields dynamically, the field length is a bit long, thus I 'do' have some white space on the right - perhaps that's the problem here.  I count 10 'blanks' - I'll retry with a (-11) instead...
Give me another half hour or so...
0
 
LVL 67

Author Comment

by:sirbounty
ID: 17099466
Now getting
ce 4

Shaving to 8... : |
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best way to parse out a json string in VB6? 10 163
Access Object Property from VBA Module in Excel 2010 2 31
Macro Excel - Multiple If conditions 2 71
vbModal 12 51
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

805 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