473,769 Members | 5,518 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

query to self table

dear respected sir,

i have so much strange behavior of access queries using through VBA
codes

here is the structure of tables
- tblMaster(where PK is PolicNo)
- tblDetails

so there is 1-TO-many relation between above tables. when the policy
issues, user has to enter details of vehciles under details table.now
every end of year we have to renew policies of clients, so master
policies i renew using deuplicate record method

DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

so what happend i take input user to renew(re-issue) with current
details of new policy and keep stores as new record. now the question
raised how to renew details. as details can't renew all in one shot
with above codes...

so i write a query that inster record via variable(policy no) and select
from previous policy(as variable) and insert into it.

now the above relation is cascade-update/intergrity enforce...if i keep
this relation it never works, and if i removed it start working can any
one put highlight and share ideas of self query/co-query how to do
this...as i try 100 of methods never success in this

i do have integrity issues, however b4 this i never faced this, can any
one tell with aliases explample if the same table is select and same
table v hve to insert/append what is the best practise method

=============== =============== =============== =============== =============== ===
Public Function Motor_Policy_In sert(strNewPoli cy As String,
strOldPolicy As String)

strSQL = "INSERT INTO [tbldetails] (
POLICYNO,PlateN o,InsuredAmt,Pr emium" & _
" SELECT " & _
" '" & strNewPolicy & "',PlateNo,Insu redAmt,Premium" & _
" FROM tbldetails " & _
" WHERE ((([tblpolicy.POLIC YNO)='" & strOldPolicy & "')); "

DoCmd.RunSQL strSQL
End Function
=============== =============== =============== =============== =============== ====
rgds
shahzad

Nov 13 '05 #1
5 2004
sa**********@gm ail.com wrote:
dear respected sir,

i have so much strange behavior of access queries using through VBA
codes

here is the structure of tables
- tblMaster(where PK is PolicNo)
- tblDetails

so there is 1-TO-many relation between above tables. when the policy
issues, user has to enter details of vehciles under details table.now
every end of year we have to renew policies of clients, so master
policies i renew using deuplicate record method

DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

so what happend i take input user to renew(re-issue) with current
details of new policy and keep stores as new record. now the question
raised how to renew details. as details can't renew all in one shot
with above codes...

so i write a query that inster record via variable(policy no) and select
from previous policy(as variable) and insert into it.

now the above relation is cascade-update/intergrity enforce...if i keep
this relation it never works, and if i removed it start working can any
one put highlight and share ideas of self query/co-query how to do
this...as i try 100 of methods never success in this

i do have integrity issues, however b4 this i never faced this, can any
one tell with aliases explample if the same table is select and same
table v hve to insert/append what is the best practise method

=============== =============== =============== =============== =============== ===
Public Function Motor_Policy_In sert(strNewPoli cy As String,
strOldPolicy As String)

strSQL = "INSERT INTO [tbldetails] (
POLICYNO,PlateN o,InsuredAmt,Pr emium" & _
" SELECT " & _
" '" & strNewPolicy & "',PlateNo,Insu redAmt,Premium" & _
" FROM tbldetails " & _
" WHERE ((([tblpolicy.POLIC YNO)='" & strOldPolicy & "')); "

DoCmd.RunSQL strSQL
End Function
=============== =============== =============== =============== =============== ====
rgds
shahzad


Some things to consider.

You can substitue lines like DoCmd.DoMenuIte m acFormBar.... with
Docmd.Runcmd acCmd...
Using RunCmd is much more expressive. There are many constants, but if
you want to copy, paste, etc they are easy enough to find in the list.

You may also want to look at Docmd.GoToRecor d. Look at GoToRecord in help.

Another thing you may want to look at is VBA. Here is some example code
to add a record to a table and then move to that record in a form.

In this example, I'll add a name to a table called Test and move to that
record.

Sub AddRec
Dim rst As DAO.Recordset
set rst = Me.Recordsetclo ne

'add record
rst.AddNew
rst.FirstName = "Joe"
rst.LastName = "Blow"
rst.Update
rst.Bookmark = rst.LastModifie d

Me.Bookmark = rst.Bookmark
End Sub

I know I didn't understand what you wanted to accomplish but some of
these things may help you out.


Nov 13 '05 #2
sa**********@gm ail.com wrote:
dear respected sir,

i have so much strange behavior of access queries using through VBA
codes

here is the structure of tables
- tblMaster(where PK is PolicNo)
- tblDetails

so there is 1-TO-many relation between above tables. when the policy
issues, user has to enter details of vehciles under details table.now
every end of year we have to renew policies of clients, so master
policies i renew using deuplicate record method

DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

so what happend i take input user to renew(re-issue) with current
details of new policy and keep stores as new record. now the question
raised how to renew details. as details can't renew all in one shot
with above codes...

so i write a query that inster record via variable(policy no) and select
from previous policy(as variable) and insert into it.

now the above relation is cascade-update/intergrity enforce...if i keep
this relation it never works, and if i removed it start working can any
one put highlight and share ideas of self query/co-query how to do
this...as i try 100 of methods never success in this

i do have integrity issues, however b4 this i never faced this, can any
one tell with aliases explample if the same table is select and same
table v hve to insert/append what is the best practise method

=============== =============== =============== =============== =============== ===
Public Function Motor_Policy_In sert(strNewPoli cy As String,
strOldPolicy As String)

strSQL = "INSERT INTO [tbldetails] (
POLICYNO,PlateN o,InsuredAmt,Pr emium" & _
" SELECT " & _
" '" & strNewPolicy & "',PlateNo,Insu redAmt,Premium" & _
" FROM tbldetails " & _
" WHERE ((([tblpolicy.POLIC YNO)='" & strOldPolicy & "')); "

DoCmd.RunSQL strSQL
End Function
=============== =============== =============== =============== =============== ====
rgds
shahzad


Some things to consider.

You can substitue lines like DoCmd.DoMenuIte m acFormBar.... with
Docmd.Runcmd acCmd...
Using RunCmd is much more expressive. There are many constants, but if
you want to copy, paste, etc they are easy enough to find in the list.

You may also want to look at Docmd.GoToRecor d. Look at GoToRecord in help.

Another thing you may want to look at is VBA. Here is some example code
to add a record to a table and then move to that record in a form.

In this example, I'll add a name to a table called Test and move to that
record.

Sub AddRec
Dim rst As DAO.Recordset
set rst = Me.Recordsetclo ne

'add record
rst.AddNew
rst.FirstName = "Joe"
rst.LastName = "Blow"
rst.Update
rst.Bookmark = rst.LastModifie d

Me.Bookmark = rst.Bookmark
End Sub

I know I didn't understand what you wanted to accomplish but some of
these things may help you out.


Nov 13 '05 #3
dear sir,

the issue with details table neither on form..i wanted to do via vba
codes can any one assist this

rgds
shahzad

Nov 13 '05 #4
sa**********@gm ail.com wrote:
dear sir,

the issue with details table neither on form..i wanted to do via vba
codes can any one assist this

rgds
shahzad


Your English is very difficult to understand. Very few people, if you
are lucky there may be one, will understand your statement "the issue
with details table neither on form".

Are there newsgroups regarding Access in your native language?
Microsoft has its own newsgroups. Check for them under microsoft.publi c.*

Nov 13 '05 #5
In message <I%************ ******@newsread 1.news.pas.eart hlink.net>,
Salad <oi*@vinegar.co m> writes
sa**********@g mail.com wrote:
dear sir,
the issue with details table neither on form..i wanted to do via vba
codes can any one assist this
rgds
shahzad


Your English is very difficult to understand. Very few people, if you
are lucky there may be one, will understand your statement "the issue
with details table neither on form".

Are there newsgroups regarding Access in your native language?
Microsoft has its own newsgroups. Check for them under
microsoft.publ ic.*


The comp.databases. ms-access newsgroup charter doesn't forbid foreign
language posts. They may not get many replies but there is no harm in
trying. With any luck someone else will be able to handle the
translations.
--
Bernard Peek
London, UK. DBA, Manager, Trainer & Author. Will work for money.

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
11535
by: sreddy | last post by:
I am trying to write a sql query on self referencing table. Just to brief ..Database is related to a Hiring department of the Qwest company. I need to generate a Report used by in HR department to pay the employees who have referred the candidates for the jobs in their .. This report is used by the HR department to get the required
4
2659
by: Orion | last post by:
Hi, This is kind of last minute, I have a day and a half left to figure this out. I'm working on a project using ms-sqlserver. We are creating a ticket sales system, as part of the system, I need to be able to do a search for specific tickets withing price ranges, different locations within the theaters, etc. etc. My problem is in the search one of the criteria is to search for a group of seats together. For example let's say...
4
4466
by: Shahzad | last post by:
dear respected gurus, I would like to knew how to apply append,insert query for a self table where no primary keys issues. i do have problem say there are 5 rows of single record, this is data of motor under one policy. say policy is john2004, so john is owner of 5 cars. now on next year the card has got renew with same conditions(same amounts all), so i need to insert new recocrd via query in new policy is john2005, with same...
4
11340
by: deko | last post by:
I'm trying to update the address record of an existing record in my mdb with values from another existing record in the same table. In pseudo code it might look like this: UPDATE tblAddress SET AddressDescription of Entity 456 = AddressDescription of Entity_ID 123 Address1 of Entity 456 = Address1 of Entity_ID 123 City of Entity 456 = City of Entity_ID 123
7
1644
by: John Salerno | last post by:
Hopefully this is enough code to reveal the problem. When I run the program, there are no error messages produced, it's just that the values I enter don't seem to get put into the database, even though the query seems to be ok. def OnSaveRecord(self, event): textfield_values = for tab in self.notebook.GetCurrentPage().GetChildren(): for table in self.get_textfield_ids():
17
1783
by: erikcw | last post by:
Hi all, I'm trying to run the following query: amember_db = MySQLdb.connect(host="localhost", user="**********", passwd="*****", db="*******") # create a cursor self.amember_cursor = amember_db.cursor() # execute SQL statement sql = """SELECT payment_id FROM amember_payments WHERE
1
1705
by: write2ashokkumar | last post by:
hi... i have the table like this, Table Name : sample Total Records : 500000 (Consider like this) Sample Records: id ------------ name
1
1546
by: write2ashokkumar | last post by:
hi... i have the table like this, Table Name : sample Total Records : 500000 (Consider like this) Sample Records: ----------------
1
1270
by: write2ashokkumar | last post by:
hi... i have the table like this, Table Name : sample Total Records : 500000 (Consider like this) Sample Records: ----------------
0
9589
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
10211
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...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
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
8872
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...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5299
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.