troubleshooting Question

Access Runtime 2007 Problems

Avatar of SweetingA
SweetingA asked on
Microsoft Access
10 Comments1 Solution432 ViewsLast Modified:
detailed below is the code i have attached to a form.

This form will not run in access runtime.  Works perfectly in access and compiles without problems.

Any ideas welcome.


Private Sub Form_Current()
     Me.txtStartDate = Format(Me.txtStartDate, "dd-mmm-yy")
     Me.txtEndDate = Format(Me.txtEndDate, "dd-mmm-yy")
End Sub

Private Sub Form_Load()

    Dim LastDateOfMonth As Date
    Dim FirstDateOfMonth As Date
    Dim strMonth As String
    Dim strYear As String

    strMonth = CStr(Month(Now()))
    strYear = CStr(Year(Now()))

    Select Case strMonth
        Case "1", "3", "5", "7", "8", "10", "12"
        LastDateOfMonth = CDate("31/" & strMonth & "/" & strYear)
        FirstDateOfMonth = CDate("01/" & strMonth & "/" & strYear)
        Case "4", "6", "9", "11"
        LastDateOfMonth = CDate("30/" & strMonth & "/" & strYear)
        FirstDateOfMonth = CDate("01/" & strMonth & "/" & strYear)
        Case "2"
        If (CLng(strYear) Mod 4 <> 0) Then
            LastDateOfMonth = CDate("28/" & strMonth & "/" & strYear)
            FirstDateOfMonth = CDate("01/" & strMonth & "/" & strYear)
        Else
            LastDateOfMonth = CDate("29/" & strMonth & "/" & strYear)
            FirstDateOfMonth = CDate("01/" & strMonth & "/" & strYear)
        End If
       
    End Select

    Me.txtStartDate = FirstDateOfMonth
    Me.txtEndDate = LastDateOfMonth
    Me.TechnologyGroup = "*"
    Me.Machine = "*"
    Me.ProductID = "*"
    Dim A As String
    Dim B As String
    A = Me.txtStartDate
    B = Me.txtEndDate
    Me.Form.Filter = "[Date] Between #" & Format(A, "dd-mmm-yyyy") & "# AND #" & Format(B, "dd-mmm-yyyy") & "# "
    Me.Form.FilterOn = True
    Call LeftClick
End Sub

Private Sub TechnologyGroup_BeforeUpdate(Cancel As Integer)
    Me.Machine = "*"
    Me.ProductID = "*"
End Sub

Private Sub Machine_BeforeUpdate(Cancel As Integer)
    Me.TechnologyGroup = "*"
    Me.ProductID = "*"
End Sub

Private Sub ProductID_BeforeUpdate(Cancel As Integer)
    Me.TechnologyGroup = "*"
    Me.Machine = "*"
End Sub

Private Sub txtStartDate_AfterUpdate()
  Dim A As String
  Dim B As String
  Me.TechnologyGroup = "*"
  Me.Machine = "*"
  Me.ProductID = "*"
  A = Me.txtStartDate
  B = Me.txtEndDate
  Me.Form.Filter = "[Date] Between #" & Format(A, "dd-mmm-yyyy") & "# AND #" & Format(B, "dd-mmm-yyyy") & "# "
  Me.Form.FilterOn = True
  Call LeftClick
End Sub

Private Sub txtEndDate_AfterUpdate()
  Dim A As String
  Dim B As String
  Me.TechnologyGroup = "*"
  Me.Machine = "*"
  Me.ProductID = "*"
  A = Me.txtStartDate
  B = Me.txtEndDate
  Me.Form.Filter = "[Date] Between #" & Format(A, "dd-mmm-yyyy") & "# AND #" & Format(B, "dd-mmm-yyyy") & "# "
  Me.Form.FilterOn = True
  Call LeftClick
End Sub

Private Sub TechnologyGroup_AfterUpdate()
  Dim A As String
  Dim B As String
  Dim C As String
  A = Me.txtStartDate
  B = Me.txtEndDate
  C = Me.TechnologyGroup.Text
  Me.Form.Filter = "[Date] Between #" & Format(A, "dd-mmm-yyyy") & "# AND #" & Format(B, "dd-mmm-yyyy") & "# AND [TechnologyGroup] = " & Chr(34) & C & Chr(34)
  Me.Form.FilterOn = True
  Call LeftClick
End Sub

Private Sub Machine_AfterUpdate()
  Dim A As String
  Dim B As String
  Dim C As String
  A = Me.txtStartDate
  B = Me.txtEndDate
  C = Me.Machine.Text
  Me.Form.Filter = "[Date] Between #" & Format(A, "dd-mmm-yyyy") & "# AND #" & Format(B, "dd-mmm-yyyy") & "# AND [Machine] = " & Chr(34) & C & Chr(34)
  Me.Form.FilterOn = True
  Call LeftClick
End Sub

Private Sub ProductID_AfterUpdate()
  Dim A As String
  Dim B As String
  Dim C As String
  A = Me.txtStartDate
  B = Me.txtEndDate
  C = Me.ProductID.Text
  Me.Form.Filter = "[Date] Between #" & Format(A, "dd-mmm-yyyy") & "# AND #" & Format(B, "dd-mmm-yyyy") & "# AND [ProductID] = " & Chr(34) & C & Chr(34)
  Me.Form.FilterOn = True
  Call LeftClick
End Sub
Private Sub Command249_Click()
On Error GoTo Err_Command249_Click

    Dim stDocName As String

    stDocName = "mac_OEE_M8"
    DoCmd.RunMacro stDocName

Exit_Command249_Click:
    Exit Sub

Err_Command249_Click:
    MsgBox Err.Description
    Resume Exit_Command249_Click
   
End Sub
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros