Anyone can help me to perfect these function??

sorry I'm new to ms access
anyone can help me to perfect these function??

If Format(Now(), "yy") = x Then
DoCmd.OpenForm MeRecord + x
End If

example : current year = 2018,it reads the 18,and open form MeRecord18.
example : current year = 2019,it reads the 19,and open form MeRecord19.
Poop HolyAsked:
Who is Participating?
 
John TsioumprisSoftware & Systems EngineerCommented:
if right(year(now),2) =xx then DoCmd.OpenForm MeRecord + x

Open in new window

0
 
NorieVBA ExpertCommented:
Try this.
    DoCmd.OpenForm "MeRecord" & Format(Now(), "yy")

Open in new window

0
 
Dale FyeCommented:
Are you going to have a separate form for every year?  Seems rather labor intensive, why would you create a separate form for each year?  The only reason I could see doing that is if you had a situation like the income tax where the calculations on the form varied from year to year.

Normally, you would use the same form, but if you only wanted to view data for a particular year, you would filter the data, something like:

docmd.OpenForm "MeRecord", , , "Format([DateField], 'yy') = 18"

In this example, "DateField" would be replaced by the column name of a field which contains the dates you want to filter on.

Hope this helps
Dale
0
 
Gustav BrockCIOCommented:
A bit smarter method is:

Const FormPrefix As String = "MeRecord"
Dim FormID As String

' x = "19"

FormID = Format(Date, "yy")
If FormID = x Then
    DoCmd.OpenForm FormPrefix & FormID
End If

Open in new window

0
 
John TsioumprisSoftware & Systems EngineerCommented:
Solution Provided
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.