Avatar of cres1121
cres1121 asked on

Modification to a Autoexec marco in Access 2010 ...

I asked and got answered a question about macros.  I initially wanted a macro to run every month only once the first monday of the month.  Well they have asked for it to be changed so that it runs the 1st working day of the month.  This would also run only once a month and by one user...  

This is the macro/Module we have been running that a expect "helped" me write (they get all the credit) .  Can anyone help me with the modifications?

' salemenreports
Function Salemenreport()

Dim dbs As Database
Dim rst As Recordset
Dim d, rs As String
Dim dn As Integer

Set dbs = CurrentDb
'Set rst = dbs.OpenRecordset("tblFirstRun", dbOpenTable)
 Set rst = dbs.OpenRecordset("tblFirstRun", dbOpenDynaset)

dt = Date 'Todays date

With rst

rs = !Run_Status
d = Format(dt, "ddd")
dn = Val(Format(dt, "d"))

  If rs = "Yes" And d = "Mon" And dn < 8 Then
        DoCmd.SendObject acQuery, "Salesmen Contract Expiration for Andy", "Excel97-Excel2003Workbook(*.xls)", "rick.hedges@markiiisys.com", "", "Maintenance Contract Expiration 90 days out", "Linus says Thank You!", True, ""
    ![Run_Status] = "No"
  End If
  If rs = "No" And dn > 8 Then
    ![Run_Status] = "Yes"
  End If
End With
End Function
Microsoft Access

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

I am going to try your suggestion just have to wait till March 1st to see if it worked...

I loved that they gave me the code.  I would like to learn it but lets face it I am not going to and will get frustrated when trying to do it.  It ran just as designed.  I will see if it will happen again April....
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy