Continuous Forms -- Data Checking

  • Thread starter Jonathan Mulder
  • Start date
J

Jonathan Mulder

I've created a Continuous form that has fields
for "Purchase Date" and "Forfeit Dates". The data is
indexed on "Purchase Date". Generally, I have 2 to 5
rows of data (i.e., 2 to 5 records). The user can change
the Purchase Date and Forfeit Date values for all the
records. When the user clicks the OK button, I want to
do data checking to ensure that:
1) Forfeit Date is AFTER Purchase Date in the record.
2) Purchase Date in current record is AFTER Forfeit Date
in previous record, and so on to last record.
If the condition is not met, I want to set focus back to
the TextBox for the Purchase Date or Forfeit Date on the
row (i.e., record) that it occurs.

How can I specify the row to set focus on? The Form
Design shows only the two TextBoxes for one row.

Thanks for any help!

Jonathan Mulder
California Department of Water Resources
Red Bluff, CA
 
G

Guest

Hi Jonathan

Qu1 I recommend having a common function called by the beforeupdate event of both the PurchaseDate and ForfeitDate controls. This is because a user can edit either of these dates in any order. Use the following as an exampl

****** code start ****

private sub txtPurchaseDate_BeforeUpdate(cancel
cancel=CheckForfeitAfterPurchase(
end su

private sub txtForfeitDate_BeforeUpdate(cancel
cancel=CheckForfeitAfterPurchase(
end su

' this function handles current recor
private function CheckForfeitAfterPurchase() as boolea
dim blnForfeitBeforePurchase as boolea

if isdate(txtForfeitDate) and isdate(txtPurchaseDate) the
if txtForfeitDate < txtPurchaseDate the
blnForfeitBeforePurchase =tru
end i
end i

CheckForfeitAfterPurchase=blnForfeitBeforePurchase
end functio

***** end code *******

Qu2 Use the subform recordsetclone for the check. Use the following as an exampl

***** code start *****

private sub txtPurchaseDate_BeforeUpdate(cancel
cancel=CheckForfeitAfterPurchase(
if not cancel the
cancel=CheckPurchaseAfterForfeit(
end i
end su

' this function handles current record compared with previous recor
private function CheckPurchaseAfterForfeit() as boolea
dim blnPurchaseBeforeForfeit as boolea
dim dtmForfeitDate as dat

if isdate(txtPurchaseDate) the
dtmForfeitDate = me.recordsetclone.fields("ForfeitDate").valu
if dtmForfeitDate < txtPurchaseDate the
blnPurchaseBeforeForfeit =tru
end i
end i

CheckPurchaseAfterForfeit=blnPurchaseBeforeForfeit
end functio

***** end code *******

please note that you may have to replace example names with names you actually use. Also this is air code...

Luc
Jonatha

----- Jonathan Mulder wrote: ----

I've created a Continuous form that has fields
for "Purchase Date" and "Forfeit Dates". The data is
indexed on "Purchase Date". Generally, I have 2 to 5
rows of data (i.e., 2 to 5 records). The user can change
the Purchase Date and Forfeit Date values for all the
records. When the user clicks the OK button, I want to
do data checking to ensure that
1) Forfeit Date is AFTER Purchase Date in the record
2) Purchase Date in current record is AFTER Forfeit Date
in previous record, and so on to last record
If the condition is not met, I want to set focus back to
the TextBox for the Purchase Date or Forfeit Date on the
row (i.e., record) that it occurs

How can I specify the row to set focus on? The Form
Design shows only the two TextBoxes for one row

Thanks for any help

Jonathan Mulde
California Department of Water Resource
Red Bluff, C
 
G

Guest

Oooops forgot to include line to move to previous record..


' this function handles current record compared with previous recor
private function CheckPurchaseAfterForfeit() as boolea
dim blnPurchaseBeforeForfeit as boolea
dim dtmForfeitDate as dat
dim rst as dao.recordse

if isdate(txtPurchaseDate) the
set rst=me.recordsetclon
rst.bookmark=me.bookmar
rst.movepreviou
if not rst.bof the
dtmForfeitDate = me.recordsetclone.fields("ForfeitDate").valu
if dtmForfeitDate < txtPurchaseDate the
blnPurchaseBeforeForfeit =tru
end i
end i
end i

CheckPurchaseAfterForfeit=blnPurchaseBeforeForfeit
end functio

hope this work
luc
Jonatha

----- Jonathan Parminter wrote: ----

Hi Jonathan

Qu1 I recommend having a common function called by the beforeupdate event of both the PurchaseDate and ForfeitDate controls. This is because a user can edit either of these dates in any order. Use the following as an exampl

****** code start ****

private sub txtPurchaseDate_BeforeUpdate(cancel
cancel=CheckForfeitAfterPurchase(
end su

private sub txtForfeitDate_BeforeUpdate(cancel
cancel=CheckForfeitAfterPurchase(
end su

' this function handles current recor
private function CheckForfeitAfterPurchase() as boolea
dim blnForfeitBeforePurchase as boolea

if isdate(txtForfeitDate) and isdate(txtPurchaseDate) the
if txtForfeitDate < txtPurchaseDate the
blnForfeitBeforePurchase =tru
end i
end i

CheckForfeitAfterPurchase=blnForfeitBeforePurchase
end functio

***** end code *******

Qu2 Use the subform recordsetclone for the check. Use the following as an exampl

***** code start *****

private sub txtPurchaseDate_BeforeUpdate(cancel
cancel=CheckForfeitAfterPurchase(
if not cancel the
cancel=CheckPurchaseAfterForfeit(
end i
end su


' this function handles current record compared with previous recor
private function CheckPurchaseAfterForfeit() as boolea
dim blnPurchaseBeforeForfeit as boolea
dim dtmForfeitDate as dat

if isdate(txtPurchaseDate) the
dtmForfeitDate = me.recordsetclone.fields("ForfeitDate").valu
if dtmForfeitDate < txtPurchaseDate the
blnPurchaseBeforeForfeit =tru
end i
end i

CheckPurchaseAfterForfeit=blnPurchaseBeforeForfeit
end functio

***** end code *******

please note that you may have to replace example names with names you actually use. Also this is air code...

Luc
Jonatha

----- Jonathan Mulder wrote: ----

I've created a Continuous form that has fields
for "Purchase Date" and "Forfeit Dates". The data is
indexed on "Purchase Date". Generally, I have 2 to 5
rows of data (i.e., 2 to 5 records). The user can change
the Purchase Date and Forfeit Date values for all the
records. When the user clicks the OK button, I want to
do data checking to ensure that
1) Forfeit Date is AFTER Purchase Date in the record
2) Purchase Date in current record is AFTER Forfeit Date
in previous record, and so on to last record
If the condition is not met, I want to set focus back to
the TextBox for the Purchase Date or Forfeit Date on the
row (i.e., record) that it occurs

How can I specify the row to set focus on? The Form
Design shows only the two TextBoxes for one row

Thanks for any help

Jonathan Mulde
California Department of Water Resource
Red Bluff, C
 
J

Jonathan Mulder

Jonathan,

Thanks for the helpful code. Actually, I've already got a
fairly robust data checking procedure. My main dilemma
right now is, after showing a message box explaining
the "data check bust", I want to SetFocus on the Text Box
where one of the two dates is located. Currently, it
seems like the focus goes right up to the TextBox on the
first record (row).
Once again, thank you for your help!

Jonathan Mulder
-----Original Message-----
Hi Jonathan,

Qu1 I recommend having a common function called by the
beforeupdate event of both the PurchaseDate and
ForfeitDate controls. This is because a user can edit
either of these dates in any order. Use the following as
an example
****** code start *****

private sub txtPurchaseDate_BeforeUpdate(cancel)
cancel=CheckForfeitAfterPurchase()
end sub

private sub txtForfeitDate_BeforeUpdate(cancel)
cancel=CheckForfeitAfterPurchase()
end sub

' this function handles current record
private function CheckForfeitAfterPurchase() as boolean
dim blnForfeitBeforePurchase as boolean

if isdate(txtForfeitDate) and isdate(txtPurchaseDate) then
if txtForfeitDate < txtPurchaseDate then
blnForfeitBeforePurchase =true
end if
end if

CheckForfeitAfterPurchase=blnForfeitBeforePurchase
end function

***** end code ********

Qu2 Use the subform recordsetclone for the check. Use the following as an example

***** code start ******

private sub txtPurchaseDate_BeforeUpdate(cancel)
cancel=CheckForfeitAfterPurchase()
if not cancel then
cancel=CheckPurchaseAfterForfeit()
end if
end sub


' this function handles current record compared with previous record
private function CheckPurchaseAfterForfeit() as boolean
dim blnPurchaseBeforeForfeit as boolean
dim dtmForfeitDate as date

if isdate(txtPurchaseDate) then
dtmForfeitDate = me.recordsetclone.fields ("ForfeitDate").value
if dtmForfeitDate < txtPurchaseDate then
blnPurchaseBeforeForfeit =true
end if
end if

CheckPurchaseAfterForfeit=blnPurchaseBeforeForfeit
end function

***** end code ********

please note that you may have to replace example names
with names you actually use. Also this is air code....
 
G

Guest

Jonathan, if the problem is returning focus to the current record consider using a variant variable to store the current record's bookmark. Once you've done your checking return using the stored bookmark..

dim varBookmark as varian

varBookmark = me.bookmar
' comparison between date

me.bookmark=varBookmar

Luc
Jonatha

----- Jonathan Mulder wrote: ----

Jonathan

Thanks for the helpful code. Actually, I've already got a
fairly robust data checking procedure. My main dilemma
right now is, after showing a message box explaining
the "data check bust", I want to SetFocus on the Text Box
where one of the two dates is located. Currently, it
seems like the focus goes right up to the TextBox on the
first record (row).
Once again, thank you for your help

Jonathan Mulde
-----Original Message----
Hi Jonathan
beforeupdate event of both the PurchaseDate and
ForfeitDate controls. This is because a user can edit
either of these dates in any order. Use the following as
an exampl
 

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