By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

Testing Data after save on continuous form

P: n/a
Hi,

I have a continuous form with 'x' amount of records.
1 field on each record is a number, of which I have a field at the top
of the form which just shows the running sum.

If I enter a new record, after I loose focus of the number field, I
perform a save record and then test the data with a calculation, but
the problem I have is that the sum field always updates a second later
than the save and calculation is performed, even though they after the
save in the code.

I understand, that to sum the records takes a fraction longer. Where
else can I put my calculation so that it runs just after the sum field
has been updated ?

The idea is that I have a field A of qty 10 copied over from another
form.
The sum of all field B (the number field on each record), must not be
allowed to go higher than A.

If the current sum is 9, then when I enter a number in the next record
in field B, I then perform a save, so that the sum field can test if
Sum(B) is now higher than A, if so, perform some action whilst still on
that record as it has already been saved.

Appreciate your help

David

Jan 4 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a

David wrote:
Hi,

I have a continuous form with 'x' amount of records.
1 field on each record is a number, of which I have a field at the top
of the form which just shows the running sum.

If I enter a new record, after I loose focus of the number field, I
perform a save record and then test the data with a calculation, but
the problem I have is that the sum field always updates a second later
than the save and calculation is performed, even though they after the
save in the code.

I understand, that to sum the records takes a fraction longer. Where
else can I put my calculation so that it runs just after the sum field
has been updated ?

The idea is that I have a field A of qty 10 copied over from another
form.
The sum of all field B (the number field on each record), must not be
allowed to go higher than A.

If the current sum is 9, then when I enter a number in the next record
in field B, I then perform a save, so that the sum field can test if
Sum(B) is now higher than A, if so, perform some action whilst still on
that record as it has already been saved.
If I understand you correctly, and I probably don't, you want to ensure
that no one enters a value in field B that causes the sum of all B to
be higher than A. It sounds like you already have a textbox on your
form that holds the running sum for B. Let's assume that textbox is
called txtSumB and the textbox that holds your value for A is called
txtA and that you have a third textbox where you enter a new value to
be added to B called txtB. In that case I would put some code in the
BeforeUpdate event of B to the effect of:

if txtB + txtSumB txtA then
msgbox "B cannot be higher than " & cstr(txtA - txtSumB)
txtB.Undo ' undo your changes to textbox txtB
Cancel = True ' cancel the update for this record
txtB.SetFocus ' set focus to txtB so user can enter a different value
end if

This will prevent you from actually saving the record with an illegal
value for B.

Hope this helps.

Bruce

Jan 4 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.