CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 How to run Append query in Access Database through CCS

Print topic Send  topic

Author Message
Farooq Ahmed
Posted: 09/29/2005, 9:02 PM

I use Access, CCS and ASP
I want to transfer data from one table to other as soon as data is entered through form. For this, I wrote an append query in Access Query builder. Now, I want to run this query as data is submitted in a field. How will I run the query when we press submit button of record form. Could anyone suggest any suitable solution in CCS for transferring data from one table to other as soon as data is stored in the fields on Submit form action?
marcwolf


Posts: 361
Posted: 09/29/2005, 9:15 PM

The only way I can easily think off is to use the After Insert event of CCS.

The question is more likely - can one use pre-defined Access queries within CCS. I have seen this done in other languages (ASP) so you should be able to research on the net that way.

Hope this helps

Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
View profile  Send private message
dhodgdon

Posts: 80
Posted: 09/30/2005, 6:51 AM

I do this using the Execute Method. Because I don't write SQL very well, I build the query in Access. I then copy the SQL that Access generates and run it in the Execute Method. I found that it is easiest if you assign the SQL to a function variable first and run the Execute Method using the variable. Keep in mind that you will have to edit the SQL to make it work, like double quoting the " character, etc.

There is one caveat to this though. Access has functions that are a superset of ODBC functions and will not work if you use ODBC as your database connection. I get around this by using the JET database engine on the server instead of ODBC. For a more detailed discussion on this, I entered detailed information in the Tips and Solutions section of this forum titled "Sums, Averages and other calculated values" http://forums.codecharge.com/posts.php?post_id=59537. If you don't use Access specific functions you can continue to use ODBC.

To accomplish what you want to do, you would place the Execute Method in an event that occurs after the data is written to the database, (eg. Server After Update or Server Before Unload).

Here is example code based on Access generated SQL for an Update Query. This SQL must use the JET engine because of use of the Access DAvg function. I double quoted all " characters and used the &_ wrapping append character to make the code more readable.

davgfunction = "UPDATE Sessions INNER JOIN Results ON Sessions.SessionID = Results.SessionID SET " &_  
"Sessions.OverallQuality = DAvg(""[ovrallsesquality]"",""results"",""[sessionid]='" & urlsession & "'""), " &_  
"Sessions.OverallClarity = DAvg(""[ovrallclarity]"",""results"",""[sessionid]='" & urlsession & "'""), " &_  
"Sessions.OverallRefMaterials = DAvg(""[ovrallrefmaterials]"",""results"",""[sessionid]='" & urlsession & "'""), " &_  
"Sessions.OverallPresMaterials = DAvg(""[ovrallpresmaterials]"",""results"",""[sessionid]='" & urlsession & "'""), " &_  
"Sessions.OverallPrework = DAvg(""[ovrallprework]"",""results"",""[sessionid]='" & urlsession & "'""), " &_  
"Sessions.OverallSpeaker = DAvg(""[ovrallspkrquality]"",""results"",""[sessionid]='" & urlsession & "'""), " &_  
"Sessions.OverallUsefulness = DAvg(""[ovrallusefulness]"",""results"",""[sessionid]='" & urlsession & "'""), " &_  
"Sessions.NumOfResponses = DCount(""[ovrallsesquality]"",""results"",""[sessionid]='" & urlsession & "'"") " &_  
"WHERE (((Sessions.SessionID)=""" & urlsession & """));"  
  
dbconnection.open  
	dbconnection.Execute davgfunction  
dbconnection.close

_________________
Regards,
David Hodgdon
View profile  Send private message
dhodgdon

Posts: 80
Posted: 09/30/2005, 7:01 AM

Just one thing I forgot to specifically mention above. You cannot directly run a query that resides in the Access database from outside a MS Access application. You must use SQL. This is why I used the Execute Method. For more information on the Execute Method, look it up in CCS help.
_________________
Regards,
David Hodgdon
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.