Select to view content in your preferred language

Related Table Error on New Feature Creation

711
3
04-28-2010 08:14 AM
JayKappy
Frequent Contributor
I have an app that I was running a single feature class update on.
I was able to add points no problem.

I then related a table to the feature class
I added some code that will allow the user to add some data in some textboxes and then click a save button, this will then add the record to the related table (instead of using the bulky related table entry form)

When I add the point now I get an error that the column cannot contain a null value.
I assume that this is the field that being used as the primary key between the feature class and the related table???

If I click OK to the error it goes away and allows me to continue.
If I then look at the related table in the form I can see that there is no vlaue there for the primary key field....
I then enter my data on the form and then click a save button...this prompts some code that sends a SQL statement and adds a record in the related table. This works fine....

ALTHOUGH IF I click on a existing feature class point I do not get this error, even if there are no records in the related table...

Any one have any thoughts as to what can be firing this error....which seems to only be fired when I add a new feature...

It errors on the red below....what I am doin before the update is getting a varaible which was set on app open and finding the highest record value to create a Unique ID....The Update fails, ALTHOUGH the code still runs and returns the two values just mentioned to the form.

I really dont knwo whats going on here......thanks

THanks


'....snip

Dim objRS1, objEFPageOneControls, objEditForm,  objEFPageTwoControls, objSelLayer1
Set objSelLayer1 = Map.SelectionLayer
Set objRS1 = objSelLayer1.Records

objRS1.Bookmark = Map.SelectionBookmark

Set objEditForm = application.map.layers("Retaining_Walls").forms("EDITFORM")
Set objEFPageOneControls = objEditForm.Pages("page1").Controls

objEFPageOneControls("txtUniqueID").Value = MaxID2

Dim selectedUser
selectedUser = Application.UserProperties("LoggedInEmployee")    

objEFPageOneControls("cbo_User").Value = selectedUser
objEFPageOneControls("cbo_User").Enabled = False
objEFPageOneControls("txtUniqueID").Enabled = False

objRS1.Update
Set objRS1 = Nothing

'....snip
Tags (3)
0 Kudos
3 Replies
JayKappy
Frequent Contributor
If I remove the related table and KEEP all the code I have the error goes away....

Why is a related table causing the error when I go to add another feature?????

Or is it something else that I am missing....

Can I turn errors off until the update is done adn then turn them on Again?  I dotn watn to do this but I need a fix.....

Thanks
0 Kudos
JayKappy
Frequent Contributor
I can update an existing record fine, and write to the related table with my SQL code.

I error when I add a new Feature (same code), says "The Column Cannot contain null values"  This has to be because The record is not yet in the related table (my unique Value), and the relate is confused
If I cancel the error and run my code the record is not updated/created in the related table.

Although if I go into the related table tab and click it asks me if I want to add a record, I say yes and it brings across my Uniqe Value and allows the user to input the new related record.

I am confused here....could it be my Primary Key, or is it the OBJECTID????
When I add a point do I have to create a new related table record right off the bat?  Where as if I already have a feature I created the relation to the related table?

Any thoughts?
0 Kudos
JayKappy
Frequent Contributor
.................
0 Kudos