On 27 Nov 2004 00:07:35 -0800,
shahzadster@gmail.com (Shahzad) wrote:
[color=blue]
>dear Gurus,
>
>yes there is master/details is there, plateno is part of details,
>where is policyno is primary key in master tables and relation is
>1-to-Many
>
>now the question is this this is a self join query, we issue a policy
>in master, policyno=A0604J0205,where there are no details available,
>whoever i have cascade update also between this two tables[/color]
I do not understand. A "Self Join Query" is one in which you create a
Query by adding a table to the query grid TWICE, joining one instance
of the table to the other instance of the table. This is sometimes
useful in a heirarchy or other special circumstances; but I do not see
how a self join is useful or relevant in this case.
[color=blue]
>now i need to run such query which will collect(select all records
>from details of A0406J0204), and insert/append AS A0604J0205[/color]
This would just be a simple Append query. You can append from a table
into the same table; this is *NOT* considered a "self join" query.
Maybe that's where the confusion is coming from!
[color=blue]
>this is VBA query, if any one send any kind of normal query will also
>sufficent/fruitfull
>+++++++++++++++++++++++++++++++++++++
>Public Function Motor_Insert2()
>
>strSQL = "INSERT INTO tblDetails (POLICYNO, VEHICLES, MODEL, PlateNo )
>" & _
>" SELECT " & _
>" tblDetails.POLICYNO, tblDetails.VEHICLES, tblDetails.MODEL,
>tblDetails.PlateNo " & _
>" FROM tblDetails " & _
>" WHERE (((tblDetails.POLICYNO)= '" & A0604J0205 & "')); "[/color]
This will find all of the existing records in tblDetails where
PolicyNo is A0604J0205 and append them into tblDetails. Of course
there are two problems here: 1) there aren't any records with that
policy number in tblDetails (yet); and 2) if there were, you couldn't
append them because they'd violate the Primary Key constraint!
Try:
strSQL = "INSERT INTO tblDetails " & _
" (POLICYNO, VEHICLES, MODEL, PlateNo )" & _
" SELECT 'A0604J0205' AS PolicyNo, " & _
" tblDetails.VEHICLES, tblDetails.MODEL,tblDetails.PlateNo " & _
" FROM tblDetails " & _
" WHERE (((tblDetails.POLICYNO)= '" & A0604J0204 & "')); "
This will *search* for the data from policy A0604J0204, and construct
a new record with a new policy number, A0604J0205.
John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps