I think you need something like
DIM Q AS BYTE
Q = DatePart("q", Date())
If Q = 1 Then CompletedDate1 = Date()
If Q = 2 Then CompletedDate2 = Date()
If Q = 3 Then CompletedDate3 = Date()
If Q = 4 Then CompletedDate4 = Date()
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a form that I use for task scheduling and keeping track of dates when I performed that task. It is a simple form where I have a "STATUS" field combo box with "Not Started" and "Completed" for source options. Also, in the sourced table, I have columns identified for each of the four quarters in the year. I need help with the code that, if "STATUS" is selected "Completed", and today is, for example, is in the second quarter of this year, THEN enter "TODAYS DATE" in the "Quarter2" field.
Thanks,
Jeff Bomberger
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
I think you need something like
DIM Q AS BYTE
Q = DatePart("q", Date())
If Q = 1 Then CompletedDate1 = Date()
If Q = 2 Then CompletedDate2 = Date()
If Q = 3 Then CompletedDate3 = Date()
If Q = 4 Then CompletedDate4 = Date()
Right now, I manually go in and change the code to save the data in the correct associated table field, "CompletedDate#" (1, 2, 3, or 4). Has to be a better way of doing it...
Jeff
Thanks! I added/modified my code to include your changes, and it seemed to work.
Dim Q As Byte
Q = DatePart("q", Date)
If ([Status] = "Completed") And Q = 1 Then
[CompletedDate1] = Date
End If
If ([Status] = "Completed") And Q = 2 Then
[CompletedDate2] = Date
End If
If ([Status] = "Completed") And Q = 3 Then
[CompletedDate3] = Date
End If
If ([Status] = "Completed") And Q = 4 Then
[CompletedDate4] = Date
End If
"I need to store multiple dates in the table is the reason for the 4 fields"
Unfortunately, multiple date fields for the same data is an inappropriate table design for a relational database application.
In turn, that table design forces you to adopt workarounds like this one to try to manage the data.
You've been given a workaround that allows you to preserve that flawed table design, but that is not really the most appropriate way to handle it.
These dates should be in a child table called something like "TaskCompletion".
In that table you need one field for the foreign key to the task table, one field for the Quarter, and one field for the actual completion date.
There are many excellent resources available on the internet to help you learn how to properly design tables for a relational database application. The process is called "Database Normalization", to distinguish it from other sorts of "normalization".
You would probably benefit a lot from investing time to learn about Database Normalization and applying it to this project. Otherwise, the workarounds needed to manage inappropriately designed tables keep getting in the way of productivity.
Thank you VERY much for the advice and I will indeed be visiting information on Database Normalization!!! This was a very simple task scheduling and completion database that I use, and it works, but not very efficiently.
Jeff