default data based on data in another field.

  • Thread starter Thread starter Ashley
  • Start date Start date
A

Ashley

Hello, my database concerns absenteeism of employees. My fields are "emplID"
"StartDate" "StartTime" "EndDate" "EndTime" and "Reason"

Since several of the reasons are intra-day (meetings, training, etc..) the
start dates and end date are often the same, but not always. I would like to
make the default for the end date to be whatever the user puts in for start
date.

If you can help me, I would really appreciate it!!

Thank you!
 
Hello, my database concerns absenteeism of employees. My fields are "emplID"
"StartDate" "StartTime" "EndDate" "EndTime" and "Reason"

Since several of the reasons are intra-day (meetings, training, etc..) the
start dates and end date are often the same, but not always. I would like to
make the default for the end date to be whatever the user puts in for start
date.

If you can help me, I would really appreciate it!!

Thank you!

Sure, and you could even make this sensitive to the reason, if the reason is
selected first.

Open the form in design view. Select the StartDate field; view its Properties;
on the Events tab find the "AfterUpdate" event. Click the ... icon by it and
edit the code to something like

Private Sub StartDate_AfterUpdate()
If Me!Reason IN ("Training", "Meeting", <other intraday reasons>) Then
If IsNull(Me!EndDate) Then ' don't stomp on already entered enddate
Me!EndDate = Me!StartDate
End If
End If
End Sub
 
Thank you for your help!!! I can't seem to get it to work. I am not very
familiar with Access, but my boss has asked me to come up with this table..
HA. I put this code in where you said to, but after I put in the start date,
nothing happens in the end date field. Also, does this only work in the form
interface, or will it carry over into the spreadsheet view.

Again, I am not an experienced Access user, so please forgive my ignorance!!
 
Thank you for your help!!! I can't seem to get it to work. I am not very
familiar with Access, but my boss has asked me to come up with this table..
HA. I put this code in where you said to, but after I put in the start date,
nothing happens in the end date field. Also, does this only work in the form
interface, or will it carry over into the spreadsheet view.

Please copy and paste your actual code. Also indicate both the fieldnames of
the date fields in your table, and the names of the Form controls. If you're
using a Subform let us know that too.

If by "spreadsheet view" you mean the Table Datasheet (Access doesn't use
spreadsheets...), then no; table datasheets have no usable events. If you mean
that the Form is displayed in Datasheet view, then yes it should work.
 
Back
Top