SweetingA
asked on
Access Runtime 2007 Problems
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_BeforeUpda te(Cancel As Integer)
Me.Machine = "*"
Me.ProductID = "*"
End Sub
Private Sub Machine_BeforeUpdate(Cance l As Integer)
Me.TechnologyGroup = "*"
Me.ProductID = "*"
End Sub
Private Sub ProductID_BeforeUpdate(Can cel 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_AfterUpdat e()
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
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_BeforeUpda
Me.Machine = "*"
Me.ProductID = "*"
End Sub
Private Sub Machine_BeforeUpdate(Cance
Me.TechnologyGroup = "*"
Me.ProductID = "*"
End Sub
Private Sub ProductID_BeforeUpdate(Can
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_AfterUpdat
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
Some users do not have MS Access so i created a runtime variant for them using Microsofts free runtime software.
This is the only query/form/report out of a much larger database that does not run.
Yes its in a trusted location.
The error is "execution of this application has stopped due to a runtime error"
i am not very familiar with runtime so i don't know if t has all the functionality of access.
Regards
This is the only query/form/report out of a much larger database that does not run.
Yes its in a trusted location.
The error is "execution of this application has stopped due to a runtime error"
i am not very familiar with runtime so i don't know if t has all the functionality of access.
Regards
You have more runtime experience than I do. ;-)
Do you get this error as soon as you attempt to open the form? Or is the error associated with a particular action on the form?
Did you compile the application prior to creating the runtime version? If not, try that to see whether there is a compilation problem with that form.
BTW, you can replace a lot of code in the Form_Load event if you would use:
LastDateOfMonth = DateSerial(Year(Date()), Month(Date()) + 1, 0)
FirstDateOfMonth = DateSerial(Year(Date()), Month(Date()), 1)
or for the first day of the month:
FirstDateOfMonth = Date() - Day(Date()) + 1
Do you get this error as soon as you attempt to open the form? Or is the error associated with a particular action on the form?
Did you compile the application prior to creating the runtime version? If not, try that to see whether there is a compilation problem with that form.
BTW, you can replace a lot of code in the Form_Load event if you would use:
LastDateOfMonth = DateSerial(Year(Date()), Month(Date()) + 1, 0)
FirstDateOfMonth = DateSerial(Year(Date()), Month(Date()), 1)
or for the first day of the month:
FirstDateOfMonth = Date() - Day(Date()) + 1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also, I've never seen anyone apply a filter using:
Me.Form.FilterOn = True
I always use:
me.FilterOn = true
although your method may work, I cannot recall ever seeing it used that way, because Me actually refers to the form (or report)
Me.Form.FilterOn = True
I always use:
me.FilterOn = true
although your method may work, I cannot recall ever seeing it used that way, because Me actually refers to the form (or report)
ASKER
I am not sure why but removing the .text solved the problem.
All other items were in order.
Thankyou very much.
All other items were in order.
Thankyou very much.
Glad I could help.
If you have experience with VB, the Text property is the default, but in Access the Value property of a control is the default.
I frequently use .Text when I'm working with a controls Change event (like in a textbox that is being used for real-time filtering), but rarely use it elsewhere.
If you have experience with VB, the Text property is the default, but in Access the Value property of a control is the default.
I frequently use .Text when I'm working with a controls Change event (like in a textbox that is being used for real-time filtering), but rarely use it elsewhere.
Side note to fyed:
The keyword “Me” exists in all class modules, and refers to the class. For class modules attached to a form, a number of objects are pre-defined, namely the form and all controls on it, with events. So “Me.Form” refers to the form, and is also the default property of “Me”. The filter of the form is formally “Me.Form.Filter”, but can be written as “Me.Filter” (the most often seen syntax), ”Form.Filter” (normal when used outside of the module, e.g. in a text box expression or a macro), and even just “Filter”.
Saying that “Me” refers to the form is thus technically incorrect, but valid from a practical point of view, in most cases. It's a very common misconception.
Cheers!
(°v°)
The keyword “Me” exists in all class modules, and refers to the class. For class modules attached to a form, a number of objects are pre-defined, namely the form and all controls on it, with events. So “Me.Form” refers to the form, and is also the default property of “Me”. The filter of the form is formally “Me.Form.Filter”, but can be written as “Me.Filter” (the most often seen syntax), ”Form.Filter” (normal when used outside of the module, e.g. in a text box expression or a macro), and even just “Filter”.
Saying that “Me” refers to the form is thus technically incorrect, but valid from a practical point of view, in most cases. It's a very common misconception.
Cheers!
(°v°)
Thanks, Markus. Appreciate the clarification.
Does it generate an error?
Which part of the code won't run? Will any of the procedures work?
Does the user have the application installed in a "trusted location"? If not, they will need to do so or none of the code will work.