Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Inserting Records

Status
Not open for further replies.

spencern

Programmer
Joined
Dec 20, 2001
Messages
78
Location
US
Hi,
I've got a page that I'm making with ASP to let teachers login and leave comments for their students. I've got one part of the form that is a yes/no question. If the user clicks yes, a new window is launched with another short form asking for missing assignments from the student. If the user inputs the information, goes back to the previous page and completes that form also, everything works fine.

The problems come up when the user clicks no to the question and goes about finishing to form. When they press submit, the DB is never updated.

The problem is that I've got the Insert Record Behavior on the second form that is opened. The behavior on the original page is an Update behavior. Obviously, you can't update a record that has never been inserted.

Is there any way I could make this work? All the data that is being inserted goes into one table because of the need to be able to delete all the information at once about a particular comment (long story). Is there any kind of "Update If...Otherwise Insert" kind of extension that anyone knows about? Or does anyone know of a way that I could make this work?

If you want to take a look at the offending pages, there at Use Adamo as username and test as password. Then click on enter comments, pick a student name, and have a look at the form.

Thanks,
Spencer
 
Hi

Have you though about combining the two forms? You are not exactly pushed for space (although I do like the popup principle).

I am not entirely sure what the problem is regarding the data. Is the student's attendance and attitude simply updated whenever the comments are left or is a new comment left each time? Do the assignments get put into a different table?

I will be able to help you out if you can throw a bit more light on these issues. There are many ways to update or insert data, we just need to find out which one is suitable for you.

Derren [The only person in the world to like Word]
 
you like Word?

OMG

There is someone!

hehe

Hey Spencer,

Why not make it two separate forms?

both insert record behaviors

 
Derren,
I was talking to a teacher at the school, and we decided that it would be easiest to have a popup second form for the missing assignments just because some kids won't have any, and we thought it would look better this way.

Right now, the missing assignments form is being entered into the comments table of the DB. When you go back to the original form and submit that, it UPDATES the information in the DB, also in the comments table.

I setup it up this way because I couldn't figure a way to make the relationships in Access work. I want to be able to press delete, and delete both the comments and the missing assignments at the same time.

Just to clarify, every time a teacher logins in to leave a comment, a whole new record is created in the DB, mainly so I can look back at previous weeks info.

I guess I could redesign the DB, but I'm still unclear if I would have to setup any relationships or could I just create the tables and let UD do the rest?

I was also thinking that I could use some hidden fields to pass the data from the popup form to the original and then Insert all of it at once with an Insert Behavior. Would this be the easy way out? Let me know.

Thanks,
Spencer
 
Spencer,

I see what the problem is now.

You should combine the two forms into one as you will then only be inserting the one record each time - no need then to worry about finding the same record to update etc. As there are only two extra fields in the popup this would make sense.

But, you could retain some of the flash window opening stuff by putting the two assignment fields into a layer and making it hidden on the page. Then, if the person selects the yes button you can show the layer, and hide it again if they choose no (make sure you reset the field values if they say no in case they started filling them in and changed their mind) or you could just leave them visible once they select yes.

Trust me, that would save you a lost of trouble without losing style marks!

Derren [The only person in the world to like Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top