Access 97 - autofill field value based on other fields in form

B

barrynichols

I have a form with a field called Proceed (Y/N)

I need this field to complete automatically based upon the values in
other fields on the form.

e.g. if Field1="Mortgage" and Field2 <>""
then Proceed = "Y"

How would I go about coding this?
 
P

Pat Hartman

In the form's BeforeUpdate event. If you are trying to check for null,
using <>"" will not work for two reasons 1- "" is a zero-length-string and
2 - any type of comparison with null will return null so you need to use the
IsNull function.

If field1 = "Mortgage" AND Not IsNull(field2) Then
.....
 
B

barrynichols

In the form's BeforeUpdate event.  If you are trying to check for null,
using <>"" will not work for two reasons 1- "" is a zero-length-string and
2 - any type of comparison with null will return null so you need to use the
IsNull function.

If field1 = "Mortgage" AND  Not IsNull(field2) Then
....









- Show quoted text -

I already have code in the BeforeEvent field to record audit changes:

Private Sub Form_BeforeUpdate(Cancel As Integer)
bWasNewRecord = Me.NewRecord
Call AuditEditBegin("tbl_Visit", "aud_tmp_tbl_Visit", "VisitID",
Nz(Me.VisitID, 0), bWasNewRecord)

End Sub

Where would I insert this code into this sub?
 
P

Pat Hartman

Before it should be fine. I don't know what your audit code is doing but
generally creating audit records is done in the AfterUpdate event once you
know that the record has been saved.
In the form's BeforeUpdate event. If you are trying to check for null,
using <>"" will not work for two reasons 1- "" is a zero-length-string and
2 - any type of comparison with null will return null so you need to use
the
IsNull function.

If field1 = "Mortgage" AND Not IsNull(field2) Then
....









- Show quoted text -

I already have code in the BeforeEvent field to record audit changes:

Private Sub Form_BeforeUpdate(Cancel As Integer)
bWasNewRecord = Me.NewRecord
Call AuditEditBegin("tbl_Visit", "aud_tmp_tbl_Visit", "VisitID",
Nz(Me.VisitID, 0), bWasNewRecord)

End Sub

Where would I insert this code into this sub?
 

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