 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 21st, 2007, 10:39 AM
|
|
Authorized User
|
|
Join Date: May 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks to rob the code has finally worked...
Here is the final code
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim wkday As Integer
wkday = Weekday(Date)
Dim dayNum As Integer
dayNum = Day(Date)
If dayNum = 2 Then
If (wkday > vbMonday And wkday < vbSaturday) Then
stDocName = "tblAshim"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
ElseIf dayNum = 4 Then
If wkday = vbMonday Or wkday = vbTuesday Then
stDocName = "tblAshim"
DoCmd.OpenForm stDocName, , , stLinkCriteria
ElseIf wkday = vbTuesday And dayNum = 3 Then
stDocName = "tblAshim"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Else
'Code does not meet above.
MsgBox "Today is not SBDOM!", _
vbCritical + vbOKOnly, _
"Title"
End If
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
End Sub
Many thanks once again Rob
|
|

June 21st, 2007, 10:49 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
|
|
EDIT: Just seen your new posts!
This code fulfills your requirements:
Code:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim wkday As Integer
wkday = Weekday(Date)
Dim dayNum As Integer
dayNum = day(Date)
If dayNum = 2 Then
If (wkday > vbSunday And wkday < vbSaturday) Then
stDocName = "tblAshim"
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
ElseIf (dayNum = 3 Or dayNum = 4) And (wkDay = vbMonday or wkDay = vbTuesday) Then
stDocName = "tblAshim"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
'Code does not meet above.
MsgBox "Bad date!", _
vbCritical + vbOKOnly, _
"Title"
End If
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
End Sub
Kind Regards,
Rob
|
|

June 22nd, 2007, 02:14 AM
|
|
Authorized User
|
|
Join Date: May 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Rob,
Many thanks for taking out time for me and helping me with the code...
|
|

June 22nd, 2007, 02:31 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
|
|
rohit_ghosh,
Your very welcome, its what the forum is all about!
Glad to hear all is working fine now, best advice I was ever given is to play with your code!
See what its doing, how it works, and why!
Good luck with the rest of your project, if you need any more info, then please ask.
Best Regards,
Rob
|
|
 |