default value

Y

Yousoft

Hi All
I want all my form objects to be default value according to last record;
there is any expression or macro to do this.
Thanks
 
A

Arvin Meyer [MVP]

No but you can try looking up the last record and setting the default value
to that. If you're doing this in the same session it's even easier: Just put
a bit of code in each textbox's AfterUpdate event:

Me!TextBoxName.DefaultValue = """" & Me!TextBoxName.Value & """"

That's 4 double quotes on either side.
 
L

Linq Adams via AccessMonster.com

The exact syntax varies with the datatype being carried forward:

For Text fields

Private Sub YourTextControlName_AfterUpdate()
If Not IsNull(Me.YourTextControlName.Value) Then
YourTextControlName.DefaultValue = """" & Me.YourTextControlName.Value &
""""
End If
End Sub

For Numeric fields

Private Sub YourNumericControlName_AfterUpdate()
If Not IsNull(Me.YourNumericControlName.Value) Then
YourNumericControlName.DefaultValue = Me.YourNumericControlName.Value
End If
End Sub

For Date fields

Private Sub YourDateControlName_AfterUpdate()
If Not IsNull(Me.YourDateControlName.Value) Then
YourDateControlName.DefaultValue ="#" & Me.YourDateControlName & "#"
End If
End 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