Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Re: Application Error on executing code

Status
Not open for further replies.

Magnetar

Programmer
Joined
Sep 22, 2001
Messages
73
Location
GB
Morning, Thanks for both your responses, regarding the above problem.

fynder,

I did all of your suggestions, but am still encountering problems! The only time the procedure executes okay, happens when I open and view the procedure itself, click anywhere in the code (I don't add anything to the code!), and then run the procedure.

On re-entering the db, am still getting 'application errors' which close the db down.

DatabaseGuy,

My code is as follows:



Private Sub Update_Click()

Dim sCaseNo As String

On Error GoTo Err_Update_Click: 'If an error occurs, refer to Error Handler.

sCaseNo = Me.CaseNo

Me.AllowEdits = True 'Set "my" (ie the form's) 'Allow Edits' property to 'Yes'.
Me.AllowAdditions = True 'Set "my" (ie the form's) 'AllowAdditions' property to 'Yes'.


Call Update_Dates(sCaseNo)


Me.AllowEdits = False 'Set "my" (ie the form's) 'Allow Edits' property to 'Yes'.
Me.AllowAdditions = False 'Set "my" (ie the form's) 'AllowAdditions' property to 'Yes'.


Exit_Update_Click: 'Exit out of 'Update' procedure.
Exit Sub


Err_Update_Click: 'Error Handler.
MsgBox Err.Description
Resume Exit_Update_Click


End Sub
------------------------------------------------------

Sub Update_Dates(sCaseNo As String)
Dim db As Database
Dim sMySql As String
Dim rstInitiation As Recordset

On Error GoTo Error_Update_Dates


sMySql = "SELECT InitiationDate FROM tblInitiation WHERE CaseNo = "
sMySql = sMySql & "'" & sCaseNo & "';"
Set db = CurrentDb
Set rstInitiation = db.OpenRecordset(sMySql)

With rstInitiation
'
' If caseno thenMe.ProvDateCalc, Me.DefDateCalc
'
If Not .EOF Then
Debug.Print , .Fields("InitiationDate")
Me.ProvDateCalc = DateAdd("m", 9, .Fields("InitiationDate"))
Me.DefDateCalc = DateAdd("m", 15, .Fields("InitiationDate"))

End If
End With



rstInitiation.Close
'db.Close


Exit_Update_Dates: 'Exit out of 'Update' procedure.
Exit Sub
---------------------------------------------------------

What do you, fynder, anyone else suggest? (Do U think the error may lie with the '.OpenRecordset(sMySql)' for example?

Please help!


Cheers, Magnetar!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top