Default value in access

K

Kurt

Hey all,

Im trying to figure out a way to make the default value of a date and ID
field within my form to represent the data entered in the previous form...

For example, say i enter 20/04/04 for the date, and an ID of paq
when I move to a blank record (new form entry), i want the date and id to
default to my last entered items (in this case, default to 20/04/04 and paq)

Is there anyway i can do this???? Any help will be appreciated
 
A

Allen Browne

Use the AfterUpdate event procedure of the control to set its Default Value.

Default Value is a string, so you need to add quote marks around the value
before assigning:

Private Sub MyDate_AfterUpdate()
With Me.MyDate
If Not IsNull(.Value) Then
.DefaultValue = """" & .Value & """"
End If
End With
End Sub
 
K

Kurt

Thanks for the quick response!

However, the solution doesn't seem to work as I intended. Wouldn't:
With Me.Date_Field
If IsNull(.Value) Then
.DefaultValue = "" & .Value = ""
End If
End With

work? This tests that the condition of the text field is empty (if isNull),
and we can then assign the value to it... but I still cant figure out a way
to input the date that is within the previous record into the new record...
any way to do this?

Cheers for your help!
 

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