adding record- want to test if controls have spcfd valuz b4 scroll

T

Ted

i have added a control btn to my form in A2K and when clicked it actuates the
following vba:

Private Sub AddRecord_Click()
On Error GoTo Err_AddRecord_Click

Forms("Screening Log").AllowAdditions = True
If Not Me.NewRecord Then DoCmd.GoToRecord , , acNewRec
Me.StudyNumber.Value = "REQUIRED"
Me.RegNumber.Value = "REQUIRED"
Me.[On-Study Date].Value = #1/1/1900#
DoCmd.GoToControl "StudyNumber"
Forms("Screening Log").Dirty = False
Forms("Screening Log").AllowAdditions = False

Exit_AddRecord_Click:
Exit Sub

Err_AddRecord_Click:
MsgBox Err.description
Resume Exit_AddRecord_Click

End Sub

what i'd like to do is assure myself that the user has not left the record
b4 inputing valid data.

i've been doing some reading and thought that perhaps the "NewRecord"
property might/could help. is this getting warm?

-ted
 
M

Michel Walsh

(...)
what i'd like to do is assure myself that the user has not left the record
b4 inputing valid data.
(...)

-ted



The Before Update event for the FORM is cancel-able: make the checks there
(or call a subroutine that does it) and specify the Cancel parameter
accordingly to the result of the validations. The BeforeUpdate event for the
form is fired before the record has to be saved.


Hoping it may help,
Vanderghast, Access MVP
 

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