Help with running a query in an onclick event

DevRev

Registered User.
Local time
Today, 02:20
Joined
Mar 30, 2006
Messages
18
Hi All,
I hope I can explain this in a way that makes it clear what I am trying to do.:confused:

I have a form with a subform on it. The main form us used to capture "header" information about deposits and the subform is used to capture individual items (checks, cash, etc). The two forms insert data in Header and detail table respetively. On the sub for a user can enter multiple detail records which are tied to one header record. The way they do this is by entering one detail record, hit enter and the subform clears and they enter the next. When they are finished they can hit "Next deposit" and start a new deposit

My issue is that someone can enter header information and not enter any detail and thereby create and "orphan" header. So I decided to make the detail information required. The problem is that as they are entering data and moving to the next record when their finished they can't get out of the loop of required fields.

So what I thought I would do is, instead of making the fields required I would have the program check whether there were any records in the detail table tied to the header table when they click "next deposit". If the ansers is "no" they would get a message saying to enter the details. If the answer is yes it would allow them to move on.

I am assuming I need to use a sql query on the onclick event for the "next deposit" button. Something like:

If
select headerid from header where headerid not in (select headerid from detail)
is true
then Messagebox


I just don't know how to do this.

Thanks for any help you can be.
 
Uncle Gizmo,
Thanks for the reply. I tried something like that. However, I need to do more than find out if the field is null. I need to find out if there is a detail record associated with the header record in the database. If a record has already been commited for detail then it's ok if the field is null but if a detail record has not been commited then the user should get a message to enter details.

Thanks
 
Uncle Gizmo,
That's exactly what I needed!

Thanks a million!
 

Users who are viewing this thread

Back
Top Bottom