I am on Windows 10 and running 32 bit Office 2016.
When I try to execute this piece of code:
Private Sub Form_Load()
If DatePart("ww", Format("01/" & Month(Date) & "/" & Year(Date), "dd/mm/yyyy", vbUseSystemDayOfWeek), vbThursday) = DatePart("ww", Date, vbThursday) Then
FromDate.Value = Format("01/" & Month(Date) - 1 & "/" & Year(Date), "dd/mm/yyyy")
ToDate.Value = DateAdd("d", -1, Format("01/" & Month(Date) & "/" & Year(Date), "dd/mm/yyyy"))
Else
FromDate.Value = Format("01/" & Month(Date) & "/" & Year(Date), "dd/mm/yyyy")
ToDate.Value = DateAdd("d", -1, Format("01/" & Month(Date) + 1 & "/" & Year(Date), "dd/mm/yyyy"))
End If
If CountRows("rpt_all_hours") > 0 Then
cmdClearTable.Enabled = True
ViewTable.Enabled = True
Else
cmdClearTable.Enabled = False
ViewTable.Enabled = False
End If
End Sub
I get an error:
Run Time Error 2683 there is no object in this control
The code stops at this line:
FromDate.Value = Format("01/" & Month(Date) - 1 & "/" & Year(Date),"dd/mm/yyyy")
I also got an Active X error when importing the form into an Access 2016 database from an .mdb
file:
There was an error loading an ActiveX control on one of your forms or reports.
What am I doing wrong?
Oh my - that code needs a thorough clean-up. Never use string handling for date manipulations, no exceptions.
As for the date picker - it is built-in in newer Access versions. Just set a date format for the textbox, and a small button is shown at the right which opens the date picker.
Then trash the old ActiveX control.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.