Auto Populate Date Field Problem

DblDogDare

Registered User.
Local time
Today, 14:18
Joined
Feb 14, 2003
Messages
17
I am having some difficulty with Auto Populating Date fields. I have a form that has multiple (7) signature blocks and each signature block has a corresponding date field where some, or all, are filled while filling out the form. (2) of these signature blocks will always have a name entered. I have an OnDirty Event to populate the date field of these 2 blocks. These are working fine. The other (5) may or may not have a Name in the sig block. However, when and if a name is entered into the sig field, I would like the default Date() automatically entered into the corresponding date field for that sig. block. Now, this date can be changed if need be. I tried entering an AfterUpdate event as such in the Code Builder;

Private Sub (SigBlockField)_AfterUpdate()
If Me![SigBlockField] IsNotNull Then
Me![SigDateField] = Date()
End Sub

I keep getting an error and can not figure out what is wrong. Any help is greatly appreciated
 
You're getting a syntax error, right? Try:

Code:
If not isnull(me![sigblockfield]) then
blah blah blah
 
Thanks Dugantrain. I knew someone with experiance would be able to help me out. I tried resarching before I asked (3 hours) and thought I'll go ahead and ask. Someone out there has probably run into this and can guide me within a few minutes. You came through for me. It worked, however I also had to add End If before my End Sub. Thanks again for the quick response.

DblDogDare
 
DblDogDare said:
I also had to add End If before my End Sub.

As an aside, you won't have had to add End If to the end if you do it like this:

Code:
Private Sub SigBlockField_AfterUpdate() 
    If Not IsNull(Me![SigBlockField]) Then Me![SigDateField] = Date() 
End Sub
 
I actually didn't know that. That's good to remember, since I typically forget to put in my "End If's" at least 80% of the time.:rolleyes:
 
You can only do it that way as long as you don't have ELSE or ELSE IF statements as part of the IF - just if evaluating one condition.
 
i'm having a problem trying to implement something like this. i have a table with 2 date fields. One is registrationDate (date someone signs up for a service) and currentDate (timestamp of when someone enters in the information into the table).

expected behavior is ... someone types a date into a form (registrationDate field) and record is created then currentDate will autopopulate in the form and table. but, currentDate is always blank.

Code:
Private Sub currentDate_AfterUpdate()
    If Not IsNull(Me![registrationDate]) Then Me![currentDate] = Date
End Sub
 

Users who are viewing this thread

Back
Top Bottom