![]() |
Sergey Kornilov admin 12/28/2012 |
Check if such a record exists first. Make bRecordExists variable store true if record exists and false in other case. if (bRecordExists) then |
M
|
mitzi author 12/31/2012 |
hi, i tired this in the AddPage Events area of the MAIN table - before record added: |
M
|
mitzi author 1/3/2013 |
I guess I have to clarify the issue |
M
|
mitzi author 1/3/2013 |
Check if such a record exists first. Make bRecordExists variable store true if record exists and false in other case. Add the following code to the end of BeforeAdd event: if (bRecordExists) then hi, i tired this in the AddPage Events area of the MAIN table - before record added: '** Check if specific record exists **** dim rsExists set dal_table=dal.Table("Map") set rsExists = dal_table.Query("Address='" & values("Address") & "'","") if (bRecordExists) then BeforeAdd=false else BeforeAdd=true end if rsExists.Close : set rsExists = Nothing I could not add a record: <<< Record was NOT added >>> Item cannot be found in the collection corresponding to the requested name or ordinal. PS. both table are empty by default.
|
![]() |
Sergey Kornilov admin 1/4/2013 |
Here is the code that verifies if such Address exists in GoogleMap table and prevents record from being added if it does. dim rsExists
|
G
|
gdmacdo 1/7/2013 |
It appears as if you are checking the value in the Map table. If it exists, then you do not add the record in the Map table but you do wish to add it to the Main table. I finally tried this in the Before Record added '** Check if specific record exists **** dim bRecordExists set dal_table2=dal.Table("GoogleMap") set bRecordExists = dal_table2.Query("Address='" & values("Address") & "'","") if (bRecordExists) then BeforeAdd=false else BeforeAdd=true end if rsExists.Close : set rsExists = Nothing and got nothing, ASPrunner application did the following:
|
M
|
mitzi author 1/7/2013 |
Thank you Sergey and Greg for your great suggestions, dim rsExists set dal_table=dal.Table("GoogleMap") set rsExists = dal_table.Query("Address='" & values("Address") & "'","") if not rsExists.eof then --rbegin--' if record exists do something--rend-- BeforeAdd = false message = "This address exists already" else --rbegin--' if not exist do something else--rend-- BeforeAdd = true end if rsExists.Close : set rsExists = Nothing
dim bRecordExists set dal_table2=dal.Table("GoogleMap") set bRecordExists = dal_table2.Query("Address='" & values("Theme") & "'","") if (bRecordExists) then BeforeAdd=true else dal_table2.Address=values("Address") dal_table2.Add() BeforeAdd=true end if rsExists.Close : set rsExists = Nothing
|
G
|
gdmacdo 1/7/2013 |
If these are your real field names then change this line: Thank you Sergey and Greg for your great suggestions, I have tried your solution as follows: GoogleMap table: before record added event code:(no problems here) and calmonthly table (which is my main table) Before record Added event (at the end, as Sergey previously mentioned): (theme is the field that is equivalent to address field in GoogleMap table) and got exactly where i was before: When I attempt to add record, application does not save the record and does not insert any record in the google Map and alsoI have to click on the "x" to close add window, then "refresh" to see that record was added to the calmonthly table. googlemap table remains empty even after that "operation" Sergey, can I post the link to the demo application here? |
M
|
mitzi author 1/7/2013 |
Thanks Greg, it not work either |
G
|
gdmacdo 1/7/2013 |
I do not see a "Theme" field on the add page. Thanks Greg, it not work either try this link please admin/admin http://demo.asprunne...rTest/login.asp |
M
|
mitzi author 1/7/2013 |
hi, Greg, |
M
|
mitzi author 1/7/2013 |
project has several tables:
|
M
|
mitzi author 1/7/2013 |
after numerous attempts i got this results: |
G
|
gdmacdo 1/8/2013 |
Follow up (Solved): after numerous attempts i got this results: 'working version of adding duplicates to two tables dim rsExists set dal_table=dal.Table("GoogleMap") 'set rsExists = dal_table.Query("Address='" & values("Address") & "'","" ) not working set rsExists = dal_table.Query("Address='Address'","") if not rsExists.eof then --rbegin--' if record exists do something--rend-- BeforeAdd = false else --rbegin--' if not exist do something else--rend-- dal_table.Address = values("Address") dal_table.Add() BeforeAdd = true end if rsExists.Close : set rsExists = Nothing the application adds data to the main table, adds data to the googlemap table but it still duplicates the data in the googlemap table <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=69256&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' /> i see that there is a line dal_table.Add() is there a something that would say da_table.DoNoTaDD() ?? |
M
|
mitzi author 1/17/2013 |
Thank you dear Greg, it worked <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=69398&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' /> |