DataEntry Auto-populate

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form in datasheet view - I'd like to have the date for the next new
record populate with the date the user enters in the first new record.
Anyone know how to do this?

Thanks,
Rachel
 
Update:
I found the code I needed and it worked - this is in a subform. When I open
the main for with the subform with the code and put in a date, the code no
longer works. Any ideas?

Thanks,
Rachel
 
Update:
I found the code I needed and it worked - this is in a subform. When I open
the main for with the subform with the code and put in a date, the code no
longer works. Any ideas?

Well, there's something wrong with the code.

If you'll post the code you're using, and indicate in what way it "no
longer works", someone may be able to tell what is wrong. As it is,
it's simply impossible to say what might be wrong, since we cannot
tell what you have done.

John W. Vinson[MVP]
 
Here's the code:

Private Sub Form_AfterUpdate()
Dim ctl As Control
For Each ctl In Screen.ActiveForm.Controls
If ctl.Tag = "Date" Then
ctl.DefaultValue = """" & ctl.Value & """"
End If
Next
End Sub

I believe it's the "ActiveForm" - being a subform, that refers to the main
form. I need the subform to be active when running this code - it woks on
the subform when I open it directly.

Thanks,
Rachel
 
Here's the code:

Private Sub Form_AfterUpdate()
Dim ctl As Control
For Each ctl In Screen.ActiveForm.Controls
If ctl.Tag = "Date" Then
ctl.DefaultValue = """" & ctl.Value & """"
End If
Next
End Sub

I believe it's the "ActiveForm" - being a subform, that refers to the main
form. I need the subform to be active when running this code - it woks on
the subform when I open it directly.

Use

For Each ctl In Me.Controls


John W. Vinson[MVP]
 
Back
Top