Avoid submit Null records to Data Base

A

Alvin

I have a form that has 3 repeating sections that are hidden and only shows up
when the user mark a check box for each section.
The problem is that when 1 or 2 check boxes are marked, the user enter the
data and hit the submit button. The remainder(s) section, wich is hidden, has
a Null record that then is stored in my data base.
Is there a way I can prevent this?
 
J

jb

Alvin,

Couple of possible opportunities to adress this.

1. You might try using script to add and remove section rather than just
hide them on the client.

2. Alternatively, (your dba probably won't like it), you could use triggers
on your database to delete records that are inserted with null values.

Neither of these ideas are elegant so I think it makes sense to continue to
solicit feedback.
 
B

Ben Walters

Hey Alvin,
This should be pretty easy to correct, you have a couple of options
1: As noted by JB, you could add some code to your form on the submit event
that strips the fields from the source xml before submitting.

2: You could place your repeating sections inside optional sections, when an
optional section is not included on the form the underlying xml is removed
from the structure so you shouldn't recieve any null records. The only issue
with this is that you have each section being added based on a check box
value, when you check the box the repeating section is shown. To get the
same type of fucntionality and keep the xml structure from being submitted
to the db you would need to hook some code up to the on change event of the
check box to add in the optional section.

3: You could handle the possiblity of a null record in your update/create
procedure and simply not add it to the database.

Hope this helps
Cheers
Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top