Hello,
I am having a problem with my VB code. I am trying to count the records in a table based on what date they were input. I can get it to count all records, but it doesn't want to count specific records. I have tried several ways of doing the if statements, and ways of entering in parameters in the dcount function.
Here is my code as it is now:
The default value of [yy] is Date() and is formatted to yy. The default value of [wing] is 18FW. I am trying to get me.RID to equal 18FW13-001. I can get it to add to the 001, but it does not start over again at a new year. i guess, what i'm trying to do is once [yy] changes to 14, as it will next year, i want it to start back at 001. As i said before, i can get it to count all of the records, but not what records are from this year only. Any advice on this would be greatly appreciated. Also, if you know of a way to do this without using VB, that would work as well.
I am having a problem with my VB code. I am trying to count the records in a table based on what date they were input. I can get it to count all records, but it doesn't want to count specific records. I have tried several ways of doing the if statements, and ways of entering in parameters in the dcount function.
Here is my code as it is now:
Code:
Private Sub Cmdref_Click()
DoCmd.GoToRecord , , acNewRec
Dim current_year As String
Dim store_yy
Dim me_yy As String
[YY].SetFocus
me_yy = Me.YY.Text
current_year = (Format(Now(), "yy"))
If me_yy = current_year Then
store_yy = DCount("[yy]", "tblQA_FOD", "[yy] =" & current_year)
Me.RID = Me.Wing & current_year & "-" & (Format(store_yy + 1, "#,000"))
'Me.RID = store_yy
End If
End Sub
The default value of [yy] is Date() and is formatted to yy. The default value of [wing] is 18FW. I am trying to get me.RID to equal 18FW13-001. I can get it to add to the 001, but it does not start over again at a new year. i guess, what i'm trying to do is once [yy] changes to 14, as it will next year, i want it to start back at 001. As i said before, i can get it to count all of the records, but not what records are from this year only. Any advice on this would be greatly appreciated. Also, if you know of a way to do this without using VB, that would work as well.