Maintennace Forms and PK queries


Author
Message
Ian Hammond
Ian Hammond
StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)
Group: Forum Members
Posts: 57, Visits: 277
Hi,

I have the following 2 queries:

1) I have a maintenance form with 2 bound textboxes, 1 textbox for a db field name (textBox1) and the other for a friendly display name (textBox2). During New i would like the friendly name to be the mirror of the field name whilst the user is inputting the data. I have set. In the Change event on textBox1 I set

     textBox2.Text = textBox.Text

When I run the app and attempt to create a new record, I enter a character into textBox1 the change event is invoked and the data is copied to textBox2 but then the character is obliterated. Any subsequent keypress results in a blank textBox1 and textBox2. I have noticed that there seems to be multiple calls to the change event when a single key is pressed.  Does anyone have an explanation for this?

2) When I update a new record I get the error "Cannot insert the value NULL into config_pk etc. I have the properties on the PrimaryKeyIsAtoIncremented= True and PrimaryKeyIsUpdateable= false. Is there another property that I should look out for?

many thanks

Replies
Paul Chase
Paul Chase
Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Hi Ian,

For you # 1 question try handling the property changing event on the business object. To enable the event look under advanced options in the business object mapper. you should be able to handle it and do something like to code below to accomplish what you want

Private Sub BizCustomers1_FieldPropertyChanging(ByVal sender As Object, ByVal e As BizCustomers.BizCustomersFieldChangingEventArgs) Handles BizCustomers1.FieldPropertyChanging

If e.FieldChanging = BizCustomers.BizCustomersFieldNames.cust_Name Then

'check to see if adding

If Me.BizCustomers1.EditingState = BusinessEditingState.Adding Then

'set shrtname field to the first 7 characters of the customer name while adding

Me.BizCustomers1.cust_ShrtName = Me.BizCustomers1.cust_Name.PadRight(7, " ").Substring(0, 7)

End If

End If

End Sub

For # 2 are you only getting the error when you update a record?

Are you using an integer PK and having SQL handle the increment or are you passing in your own PK?

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
All good questions from the guys, Ian.  Could you elaborate on #1 what you are trying to accomplish.  Also, Paul's questions on #2 are needed to help as well.  Thanks.
Ian Hammond
Ian Hammond
StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)
Group: Forum Members
Posts: 57, Visits: 277
Hi Paul,

Sorry about the delay in responding. I am trying to insert a new record. I have declared the pk to be an integer. In the Business object I have :

PrimaryKeyIsAutoIncremented= true and PrimaryKeyIsUpdatable=false.

Many thanks

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search