default value

  • Thread starter Thread starter Yousoft
  • Start date Start date
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
 
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.
 
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

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
Back
Top