DATE FROM PREVIOUS RECORD

  • Thread starter Thread starter shah228
  • Start date Start date
S

shah228

Hi,

i want to show previous date on same form in another text box when i enter a
new record on form . please tell me how solve this problem

thanks
 
Hi,
This might work, create a button, click cancel to the wizard. Right click
the button, go to properties. On the property sheet goto the Event Tab, click
in the OnClick box and click the ... button.
Select Code Builder.

Now paste this in:

'start
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
me.xx = null
me.xx = null
'repeat as needed replacing xx
exit sub
'end
(Replace xx with the names of the fields that you don't want to copy across.
The top part basically creates a new record and copies all of the values so
you have to null the ones that you don't want to copy)

This is the long way around but hope it helps.
 
You simply set the DefaultValue for the control thru its AfterUpdate event.
Once a date is entered into the field, the value will be automatically be
inserted into the field for each new record until you either manually change
it or close the form. For future reference, I've given the syntax for text
and numeric datatypes as well as dates, as they vary slightly:

For Date fields

Private Sub YourDateControlName_AfterUpdate()
If Not IsNull(Me.YourDateControlName.Value) Then
YourDateControlName.DefaultValue ="#" & Me.YourDateControlName & "#"
End If
End Sub


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
 
Back
Top