Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 5 votes, 1.80 average. Display Modes
Old 03-08-2001, 12:57 PM   #1
Member (10 bit)
 
Join Date: May 1999
Location: Orlando, FL
Posts: 975
Send a message via ICQ to artsapimp
Is it possible to call a macro you have saved in an access database directly through ASP code? If not, how would I embed the macro into the code so it works?

Thanks for any help.
artsapimp is offline   Reply With Quote
Old 03-09-2001, 03:17 AM   #2
SQL nutcase
 
mosquito's Avatar
 
Join Date: Sep 2000
Location: Belgium
Posts: 1,136
Send a message via AIM to mosquito
yes it is possible. You can do it using "office automation". You have to create an msaccess instance.

Code:
    Dim msa 
        
    Set msa = CreateObject("Access.Application.8")
    
    msa.OpenCurrentDatabase "database.mdb"
    msa.DoCmd.RunMacro "macroname"
    msa.Quit
thats it.
mosquito is offline   Reply With Quote
Old 03-09-2001, 09:25 AM   #3
Member (10 bit)
 
Join Date: May 1999
Location: Orlando, FL
Posts: 975
Send a message via ICQ to artsapimp
Thanks. That is the easiest thing I've ever seen. I am going to use that a lot. Thanks again.
artsapimp is offline   Reply With Quote
Old 03-09-2001, 09:48 AM   #4
Member (10 bit)
 
Join Date: May 1999
Location: Orlando, FL
Posts: 975
Send a message via ICQ to artsapimp
Can you do the same thing with calling a saved query?
artsapimp is offline   Reply With Quote
Old 03-11-2001, 12:06 PM   #5
Member (9 bit)
 
Join Date: Dec 1999
Location: Midland, NC, USA
Posts: 292
Pretty much.
Just use DoCmd.OpenQuery "queryname"
UncaDanno is offline   Reply With Quote
Old 03-21-2001, 11:54 AM   #6
Member (10 bit)
 
Join Date: May 1999
Location: Orlando, FL
Posts: 975
Send a message via ICQ to artsapimp
Unspecified Error

I would love to use those commands in this situation because I am lost. I have created a form which feeds into an access db. Once it's written to the database I redirect to a view.asp page which pulls the information out of the db and formats it in a print friendly format. I am stuck with this error...
Code:
error '80004005' 
Unspecified error 

/nhd/view1.asp, line 18
That is what I'm getting when trying to run a query from a database. The query runs fine in Access, I just import it out to ASP and call it my strSQL and now it's giving me this error. Here is my strSQL, please tell me what I'm doing wrong. Thanks.

Code:
strSQL = "SELECT Evaluations.RecordID, Evaluator.Evaluator, Member.Member, Title.Title, Evaluations.Evaluation_Date, Evaluations.Greeting, Evaluations.Verification, Evaluations.Probing, Evaluations.Control, Evaluations.Language, Evaluations.Courtesy, Evaluations.Accuracy, Evaluations.Problem, Evaluations.Transition, Evaluations.Retention, Evaluations.Ethics, Evaluations.Explain, Evaluations.Score"
strSQL = strSQL & " FROM Title RIGHT JOIN (Member RIGHT JOIN (Evaluator RIGHT JOIN Evaluations ON Evaluator.EvaluatorID = Evaluations.Evaluator) ON Member.MemberID = Evaluations.Member) ON Title.TitleID = Evaluations.Title"
strSQL = strSQL & " WHERE Evaluations.RecordID = " & Request.QueryString("Record")
I would use the codes shown in the previous posts, but I don't know how to make the query saved in access only pull the recordset for Request.QueryString("Record").

Thanks for any help.
artsapimp is offline   Reply With Quote
Old 03-22-2001, 03:15 AM   #7
SQL nutcase
 
mosquito's Avatar
 
Join Date: Sep 2000
Location: Belgium
Posts: 1,136
Send a message via AIM to mosquito
What are you using to run this query. ADO, DAO?

If you are using ADO, Your code should look something like this. Just make sure that "Evaluations.RecordID" is a numeric field (otherwise you have to fix quoting).

Code:
dim strSQL
dim cnn
dim cm
dim rs

set cnn = createobject("ADODB.connection")

cnn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data\db.mdb"
cnn.open

if cnn.state = 1 then
    strSQL = "SELECT Evaluations.RecordID, Evaluator.Evaluator, Member.Member, Title.Title, "
    strSQL = strSQL & "Evaluations.Evaluation_Date, Evaluations.Greeting, Evaluations.Verification, Evaluations.Probing, "
    strSQL = strSQL & "Evaluations.Control, Evaluations.Language, Evaluations.Courtesy, Evaluations.Accuracy, "
    strSQL = strSQL & "Evaluations.Problem, Evaluations.Transition, Evaluations.Retention, Evaluations.Ethics, "
    strSQL = strSQL & "Evaluations.Explain, Evaluations.Score "
    strSQL = strSQL & "FROM Title "
    strSQL = strSQL & "RIGHT JOIN (Member "
    strSQL = strSQL & "  RIGHT JOIN (Evaluator "
    strSQL = strSQL & "    RIGHT JOIN Evaluations "
    strSQL = strSQL & "    ON Evaluator.EvaluatorID = Evaluations.Evaluator) "
    strSQL = strSQL & "  ON Member.MemberID = Evaluations.Member) "
    strSQL = strSQL & "ON Title.TitleID = Evaluations.Title "
    strSQL = strSQL & "WHERE Evaluations.RecordID = " & Request.QueryString("Record")

    set cm = createobject("ADODB.command")
    cm.commandtext = strSQL
    cm.commandtype = 1 'plain text
    
    set rs = createobject("ADODB.Recordset")
    set rs = cm.execute
    
    do while not rs.eof
        response.write("Data: " & rs.fields("RecordID").value & rs.fields("Evaluator").value  & vbcrlf) 
        rs.movenext
    loop
    
    rs.close
    set rs = nothing
    set cm = nothing
    conn.close
end if

set conn = nothing
If this does not help you, you have to post more info...

regards
mosquito is offline   Reply With Quote
Old 03-22-2001, 10:39 AM   #8
Member (10 bit)
 
Join Date: May 1999
Location: Orlando, FL
Posts: 975
Send a message via ICQ to artsapimp
I copied and pasted the code and it looks pretty simple to manipulate. I changed the connectionstring path to the correct location of my db and I got the following error. I see where it looks like it's opening, but it must not be happening...

Again I have never used the format you are showing so excuse me if I sound ignorant. Thanks.

Code:
ADODB.Command error '800a0e7d' 

The application requested an operation on an object with a reference to a closed or invalid Connection object. 

?
artsapimp is offline   Reply With Quote
Old 03-22-2001, 01:33 PM   #9
SQL nutcase
 
mosquito's Avatar
 
Join Date: Sep 2000
Location: Belgium
Posts: 1,136
Send a message via AIM to mosquito
Sorry, I forgot something, change the
Code:
    set cm = createobject("ADODB.command")
    cm.commandtext = strSQL
part to
Code:
    set cm = createobject("ADODB.command")
    cm.activeconnection = cnn
    cm.commandtext = strSQL
sorry.
mosquito is offline   Reply With Quote
Old 03-22-2001, 01:52 PM   #10
Member (10 bit)
 
Join Date: May 1999
Location: Orlando, FL
Posts: 975
Send a message via ICQ to artsapimp
Thank you very much for the response. It kind of makes me feel a little better about my coding now because I got the same error...

error '80004005'
Unspecified error

?

I have also posted this at http://www.vbforums.com and noone there has come up with anything either. I have posted it as a zip file there if anyone wants to accept this challenge.

Thanks again for the help.
artsapimp is offline   Reply With Quote
Old 03-23-2001, 02:44 AM   #11
SQL nutcase
 
mosquito's Avatar
 
Join Date: Sep 2000
Location: Belgium
Posts: 1,136
Send a message via AIM to mosquito
Have you tried this code on another machine. It looks more like a problem with MDAC. I suggest that you re-install Microsoft Data Access components and try again.

http://www.microsoft.com/data/
mosquito is offline   Reply With Quote
Old 03-23-2001, 09:11 AM   #12
Member (10 bit)
 
Join Date: May 1999
Location: Orlando, FL
Posts: 975
Send a message via ICQ to artsapimp
There is another person trying it today on their server. I will look into the update though. Thanks.
artsapimp is offline   Reply With Quote
Old 03-23-2001, 11:15 AM   #13
Member (9 bit)
 
Join Date: Dec 1999
Location: Midland, NC, USA
Posts: 292
For what it's worth, error 80004005 is usually tossed back because of a permissions conflict.
Just for grins, try putting a copy of the .mdb in a subfolder where your site is physically located.
Also, since you are trying to run a macro, you may need to go into IIS mangler and tell it to allow scripts AND executables.
UncaDanno is offline   Reply With Quote
Old 03-23-2001, 01:20 PM   #14
Member (10 bit)
 
Join Date: May 1999
Location: Orlando, FL
Posts: 975
Send a message via ICQ to artsapimp
The macro is on a different application. I will try to put it somewhere else and see what happens.
artsapimp is offline   Reply With Quote
Old 03-23-2001, 01:21 PM   #15
Member (10 bit)
 
Join Date: May 1999
Location: Orlando, FL
Posts: 975
Send a message via ICQ to artsapimp
Same thing. Thanks for trying though.
artsapimp is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:55 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2