Wrox Programmer Forums
|
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
 
Old June 21st, 2007, 10:39 AM
Authorized User
 
Join Date: May 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old June 21st, 2007, 10:49 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
 
Old June 22nd, 2007, 02:14 AM
Authorized User
 
Join Date: May 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Rob,

Many thanks for taking out time for me and helping me with the code...

 
Old June 22nd, 2007, 02:31 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent:hard disk serial code and vb code ivanlaw Pro VB 6 0 July 25th, 2007 04:05 AM
VB: .Exe file, serial code and activation code ivanlaw Pro VB 6 8 July 6th, 2007 05:44 AM
code clinic - Why wont example asp code work? jardbf Classic ASP Basics 3 April 27th, 2006 06:22 PM
Writing Client Side Script from Code-Behind code sajid_pk Classic ASP Databases 1 January 18th, 2005 12:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.