473,797 Members | 3,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert CreateQueryDef of MDB project into equivalent version in ADP

7 New Member
Hi

I am beginner in the access project.
can anyone suggest how to deal with this
" Set rq = Db.CreateQueryD ef("r_temp_rslt _research", strSql)"
in the below code.As its a MDB application which needs to be converted into ADP.
Any kind of help would be highly appreciated.

Below is the snippet of code:
Expand|Select|Wrap|Line Numbers
  1. Dim Db As DAO.Database
  2. Dim rq As DAO.QueryDef
  3. Dim strSql As String
  4. Dim fResearch As Form
  5.  
  6. If IsOpen("f_research") Then
  7. Set fResearch = Forms!f_research
  8.  
  9. With fResearch
  10. .Refresh
  11. strSql = .lst_result_research.RowSource
  12.  
  13. 'Supprime la requête r_temp_rslt_research avant de la recréer
  14. On Error Resume Next
  15. DoCmd.DeleteObject acQuery, "r_temp_rslt_research"
  16. On Error GoTo 0
  17.  
  18. Set Db = CurrentDb()
  19. Set rq = Db.CreateQueryDef("r_temp_rslt_research", strSql)
  20. rq.Close
  21. Set rq = Nothing
  22. Set Db = Nothing
  23.  
  24.  
  25. .txt_tot_list_fees = Nz(DSum("listing_fees_amount", "r_temp_rslt_research"), 0)
  26. .txt_tot_cust_act = Nz(DSum("activity_cost", "r_temp_rslt_research"), 0)
  27. .txt_tot_free_goods = Nz(DSum("free_goods_tot", "r_temp_rslt_research"), 0)
  28. .txt_tot_price_off = Nz(DSum("price_off_tot", "r_temp_rslt_research"), 0)
  29.  
  30. .txt_tot_list_fees_bal = Nz(DSum("list_fees_bal_diff_0", "r_temp_rslt_research"), 0)
  31. .txt_tot_cust_act_bal = Nz(DSum("cust_act_bal_diff_0", "r_temp_rslt_research"), 0)
  32. .txt_tot_price_off_bal = Nz(DSum("price_off_bal_diff_0", "r_temp_rslt_research"), 0)
  33.  
  34. End With
  35. End If
  36.  
  37. Set fResearch = Nothing
Many Thanks
Rahul
Jun 9 '08 #1
6 2494
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi Rahul. I have added code tags for your code to make it easier to read.

The querydef line you refer to (line 19) creates a stored query definition for a query named r_temp_rslt_res earch (available as a query in the Access query window once created) from the rowsource SQL of a control on form f_research (line 7).

The control is called lst_result_rese arch (line 11), and would appear to be a listbox. As a querydef cannot be overwritten once created there is a delete line which removes the previous version of that querydef at line 15, before the new version is stored (line 19).

The purpose of the line appears to be to make the listbox rowsource query available outside of the procedure itself - the querydef is not used within your procedure thereafter.

I can't guess at what the rowsource query itself does, as there are no indications of its purpose in the code.

-Stewart
Jun 9 '08 #2
rahuldev999
7 New Member
Hi Rahul. I have added code tags for your code to make it easier to read.

The querydef line you refer to (line 19) creates a stored query definition for a query named r_temp_rslt_res earch (available as a query in the Access query window once created) from the rowsource SQL of a control on form f_research (line 7).

The control is called lst_result_rese arch (line 11), and would appear to be a listbox. As a querydef cannot be overwritten once created there is a delete line which removes the previous version of that querydef at line 15, before the new version is stored (line 19).

The purpose of the line appears to be to make the listbox rowsource query available outside of the procedure itself - the querydef is not used within your procedure thereafter.

I can't guess at what the rowsource query itself does, as there are no indications of its purpose in the code.

-Stewart

Hi Stewart

Thanks for your reply.
"strSql = .lst_result_res earch.RowSource "
here lst_result_rese arch is a listbox.
so rowsource of the listbox needs to be inserted into a view or temporary table so that i can replace that view or temporary table in the below lines
.txt_tot_list_f ees = Nz(DSum("listin g_fees_amount", "t_temp_rslt_re search"), 0)
and so on.
I have tried with view but without success.
But I think temporary table is a way where i can insert the data of the rowsource (mentioned above) and perhaps assigned the values to the
txt_tot_list_fe es and etc etc.but again i donno how to do.

Hope you will be in a postion from where you can suggest even more....!

Thanks!
Rahul
Jun 10 '08 #3
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi Rahul. I am still not clear on what you need help with. It is difficult to comment further on what you are trying to achieve without knowing any of the fields involved, or the structure of the table/queries. You have an advantage in having the database in front of you; here, all we have to go on is what you tell us.

I would ask you to post the SQL you have tried (from the rowsource of the listbox, as stored in the Access querydef) and the metadata for the tables involved (the actual field names and types, and which fields are primary or secondary keys).

I am sure there are more direct ways to achieve a sum of fees than to create a querydef dynamically to do so.

Please advise also what the listbox is really doing - what choices does the user see and why?

-Stewart
Jun 10 '08 #4
rahuldev999
7 New Member
Hi Rahul. I am still not clear on what you need help with. It is difficult to comment further on what you are trying to achieve without knowing any of the fields involved, or the structure of the table/queries. You have an advantage in having the database in front of you; here, all we have to go on is what you tell us.

I would ask you to post the SQL you have tried (from the rowsource of the listbox, as stored in the Access querydef) and the metadata for the tables involved (the actual field names and types, and which fields are primary or secondary keys).

I am sure there are more direct ways to achieve a sum of fees than to create a querydef dynamically to do so.

Please advise also what the listbox is really doing - what choices does the user see and why?

-Stewart
Hi Stewart
Here is the SQL for "strSql = .lst_result_res earch.RowSource "
SELECT * FROM sr_research WHERE Brand like 'Malts' AND (activity_brand _cancelled=0 OR activity_brand_ cancelled Is Null) AND (activity_cance lled=0 OR activity_cancel led Is Null) ORDER BY [Customer name], no_activity_mon th, [No act], Brand;

There is a form "f_brand" where user can see lot of drop down box viz.'name','bra nd','activity', 'status' etc.from where the value "Brand",a drop down box(in this case 'Malts') is selected and records are displayed in the list box "lst_result_res earch" for that brand in the same form.
There is button on the same form on the click of which will display the sum of columns in the text boxes:txt_tot_l ist_fees,txt_to t_cust_act,txt_ tot_free_goods, txt_tot_price_o ff,
txt_tot_list_fe es_bal,txt_tot_ cust_act_bal and txt_tot_price_o ff_bal.

Query for r_temp_rslt_res earch:
SELECT *
FROM sr_research
WHERE (((sr_research.[Customer name]) Like '*Albin SA*') AND ((sr_research.a ctivity_brand_c ancelled)=False Or (sr_research.ac tivity_brand_ca ncelled) Is Null) AND ((sr_research.a ctivity_cancell ed)=False Or (sr_research.ac tivity_cancelle d) Is Null))
ORDER BY sr_research.[Customer name], sr_research.no_ activity_month, sr_research.[No act], sr_research.Bra nd;

In MDb "sr_researc h" is a query ,after migration it becomes a table in sql server(adp).Now in the table,fields involved are customer name (nvarchar,50)Br and(nvarchar,50 ),activity_bran d_cancelled(bit ),activity_canc elled(bit),no_a ctivity_month(i nt),[no act](int).Pls note no keys in the sr_research.
I think this is the whole scenario,little cumbersome.

Thanks for your effort,
Many Thanks
Rahul
Jun 11 '08 #5
rahuldev999
7 New Member
Hi Stewart
Here is the SQL for "strSql = .lst_result_res earch.RowSource "
SELECT * FROM sr_research WHERE Brand like 'Malts' AND (activity_brand _cancelled=0 OR activity_brand_ cancelled Is Null) AND (activity_cance lled=0 OR activity_cancel led Is Null) ORDER BY [Customer name], no_activity_mon th, [No act], Brand;

There is a form "f_brand" where user can see lot of drop down box viz.'name','bra nd','activity', 'status' etc.from where the value "Brand",a drop down box(in this case 'Malts') is selected and records are displayed in the list box "lst_result_res earch" for that brand in the same form.
There is button on the same form on the click of which will display the sum of columns in the text boxes:txt_tot_l ist_fees,txt_to t_cust_act,txt_ tot_free_goods, txt_tot_price_o ff,
txt_tot_list_fe es_bal,txt_tot_ cust_act_bal and txt_tot_price_o ff_bal.

Query for r_temp_rslt_res earch:
SELECT *
FROM sr_research
WHERE (((sr_research.[Customer name]) Like '*Albin SA*') AND ((sr_research.a ctivity_brand_c ancelled)=False Or (sr_research.ac tivity_brand_ca ncelled) Is Null) AND ((sr_research.a ctivity_cancell ed)=False Or (sr_research.ac tivity_cancelle d) Is Null))
ORDER BY sr_research.[Customer name], sr_research.no_ activity_month, sr_research.[No act], sr_research.Bra nd;

In MDb "sr_researc h" is a query ,after migration it becomes a table in sql server(adp).Now in the table,fields involved are customer name (nvarchar,50)Br and(nvarchar,50 ),activity_bran d_cancelled(bit ),activity_canc elled(bit),no_a ctivity_month(i nt),[no act](int).Pls note no keys in the sr_research.
I think this is the whole scenario,little cumbersome.

Thanks for your effort,
Many Thanks
Rahul
In addition to the above:
There is a search button "cmd_search " on the form "f_brand" on the click of which listbox lst_result_rese arch display the data.
Jun 11 '08 #6
rahuldev999
7 New Member
In addition to the above:
There is a search button "cmd_search " on the form "f_brand" on the click of which listbox lst_result_rese arch display the data.
In short I would like to have a temporary table where I can insert records from
"strSql = .lst_result_res earch.RowSource "
I have tried doing it like this:
"strSql = .lst_result_res earch.RowSource "
str = "insert into t_temp_rslt_res earch ([No act],[Activity month],[Customer name],......"
str = str & "select [No act],[Activity month],[Customer name],....from " & strSql & ""
And when inserted successfully,pr obably i could do this:
.txt_tot_list_f ees = Nz(DSum("listin g_fees_amount", "t_temp_rslt_re search"), 0)

Thanks
Rahul
Jun 11 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
517
by: Takuya Matsumoto | last post by:
Greetings to all, I am creating a setup project for a COM component I created in C#, but I can't get the component to be registered in the client system. What I would like to achieve is an equivalent of manually registering it with "gacutil.exe" and then with "regasm.exe". I went though the support documents and read the below, but the options I have are differenct:...
3
4814
by: priscilla.jenkins | last post by:
Alright, I'm really new to SQL and VBA and all this, so I might be completely off course...but just tell me. I know C and Assembly, but that doesn't help me much here. I'm trying to create a module that creates 5 queries (that a report is based on) based on a table that the user defines. My tables are named by date (not my choice), for example: -ArchivedActions05-20-05 Everything involving that seems fine. I'm getting a syntax error...
23
2518
by: Kenneth Osenbroch | last post by:
Hi, I am having trouble translating the following lines of Visual Basic code to C. For iCounter = Len(sReference) To 1 Step -1 iSum = iSum + Val(Mid(sReference, iCounter, 1)) * iMultiplier Next fReferenceCheckSum = Right(Str(10 - (iSum Mod 10)), 1)
5
3793
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public List<RoleData> GetRoles() { return GetRoles(null, false); }
9
1640
by: aaronluna | last post by:
Hi All, I was wondering if it is possible to easily convert an asp.net user control (.ascx) into an equivalent windows app. I plan on simply duplicating the user control in a c# windows app through brute force, but am becoming pressed for time with multiple deadlines. If there is an easier way than building the entire c# app from scratch, I would greatly appreciate the advice. The form contains listboxes, buttons, labels, textboxes...
1
3602
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in some files and work on it. Let say, I want add new page to web project named websiteOrder.sln, i will open websiteOrder.sln in my local computer, connected to websiteOrder.sln located in Visual Source Safe 6.0(source safe located in another...
2
2935
by: oh4real | last post by:
Howdy all. I have pretty much NO VB/Access coding experience, but am forced to come up with a generic script/process for users with varying database designs and varying levels of expertise to use and integrate into their Dbs. Following is my script and is launched On_Open event. The script determines someone's desired upload class (test, archive or recent), executes a specific query based on that info, then writes the query results to a...
4
4458
by: =?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?= | last post by:
I have a VC# .NET project which is imported from an OCX control using AxImp. I would like to convert it into a VC++ .NET project. Is there any way to do it and how to do it?
1
5605
by: shovan mohanty | last post by:
Hi , Can anybody convert below access query into equivalent stored procedure. Also please advice in the below query,user defined function of VBA i.e anneeSelection41510() has been used in the .MDB file(access project).Now how this can be implemented in the equivalent .ADP(client/server architechture)project because obviously anneeSelection41510() function will not be recognised by the sql server." (t_activity_month.fy)=anneeSelection41510())...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10469
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10246
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7560
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.