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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with .mdb file

Status
Not open for further replies.

santastefano

Programmer
Aug 9, 2005
54
IT
I have an application that functions as an access (2000) file on any computer.
When compiled as an .mdb file it continues to function on the machine that created the file but crashes on another machine with the message “Execution of this application has stopped due to a run time error”
Both computers have the same references checked.
Visual Basic for applications
Microsoft Access 10 Object library
OLE Automation
Microsoft ActiveX Data Objects 2.1 library
Microsoft DAO object library
Here is an extract of the code that crashes
Code:
 Dim varCode As String
Dim varCompanyName As Variant
Dim varOrderNumber As Variant
Dim varTeacher As String
Dim varLanguage As String
Dim varPurpose As Variant
Dim varBook As String
Dim varTotalSessions As Integer
Dim varSessionsWeek As Integer
Dim varNumberStudents As Integer
Dim varTuition As Currency
Dim varPrivate As CheckBox
Dim varCompany As CheckBox
Dim varIn As CheckBox
Dim varOut As CheckBox
Dim rsCourses As DAO.Recordset
If Me.Tuition = 0 Or IsNull(Me.Tuition) Then
DoCmd.CancelEvent
Reply = MsgBox("Please enter a course cost or select cancel to quit without saving the record", 65, "School Run")
    If Reply = 2 Then
    DoCmd.CancelEvent
    DoCmd.GoToControl "Cancel"
    Else
    DoCmd.GoToControl "Tuition"
    End If
ElseIf Me.In.Value = Me.Out.Value Then
DoCmd.CancelEvent
Reply = MsgBox("Please select In or Out of school for location or select cancel to quit without saving the record", 65, "School Run")
    If Reply = 2 Then
    DoCmd.CancelEvent
    DoCmd.GoToControl "Cancel"
    Else
    Me.In = False
    Me.Out = False
    DoCmd.GoToControl "In"
    End If
Else
        If Forms!frmCourseBegin!Private = True Then
        Set db = CurrentDb
        Set rsCourses = db.OpenRecordset("tblcourses", dbopendynaset)
        varCode = Forms!frmCourseStart1!Code
        varTeacher = Forms!frmCourseStart1!TeacherLastName
        varLanguage = Forms!frmCourseStart1!Language
        varTotalSessions = Forms!frmCourseStart1!TotalSessions
        varSessionsWeek = Forms!frmCourseStart1!SessionsWeek
        varNumberStudents = Forms!frmCourseStart1!NumberStudents
        varTuition = Forms!frmCourseMisc!Tuition
        varPurpose = Forms!frmCourseMisc!Combo11
        varBook = Forms!frmCourseMisc!Book
        Set varPrivate = Forms!frmCourseStart1!Private
        Set varCompany = Forms!frmCourseStart1!Company
        Set varIn = Forms!frmCourseMisc!In
        Set varOut = Forms!frmCourseMisc!Out
        With rsCourses
      .AddNew   'Creates new record in the table
      !Code = varCode
      !TeacherLastName = varTeacher
      !Language = varLanguage
      !Purpose = varPurpose
      !Book = varBook
      !TotalSessions = varTotalSessions
      !SessionsWeek = varSessionsWeek
      !NumberStudents = varNumberStudents
      !Tuition = varTuition
      !Private = varPrivate
      !Company = varCompany
      !In = varIn
      !Out = varOut
      .Update   'Confirms the record to the table.
   End With
rsCourses.Close 'Closes the table
Set rsCourse = Nothing 'Sets the rsTimeTable Object to nothing.
Set db = Nothing
I have found that the problem can be fixed by changing the forms so that they save directly to the table but WORRIED that I can not understand the cause of the problem.
 
What line does it error on?

Also in the future please post in the appropriate forum...

forum705
 
“Execution of this application has stopped due to a run time error” is not a typical error message I have seen, it sounds like something a programmer would put in an error handler. Does this procedure have an error handler, or is it called by another procedure with a handler?

 
Sorry for delay, I am in Italy and attempting to change telecom suppliers has resulted in no phone for 6 weeks.
There are one or two error handlers in the application but there is nothing in this procedure and none of them return this message.
Thanks for your response.
 
Is the problem that you have references to ADO and DAO?

You explicitly declare the recordset as DAO. However the database is referenced by "set db = currentdb" and db is not declared as DAO.

The lack of capital letters in dbopendynaset could be a clue.

If it is not needed remove the tools.. references to ADO.

thanks
 
Tip: use the Option Explicit instruction.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya santastefano . . .

Hmmmm I see . . .
Code:
[blue]   Dim rsCourses As DAO.Recordset
[purple]should be:[/purple]
   Dim [purple][b]db As DAO.Database[/b][/purple], rsCourses As DAO.Recordset[/blue]
. . . and your [blue]If Then Else End If[/blue] construct is missing two closing end if:
Code:
[blue]   If Trim(Me.Tuition & "") = "" Then
      '
      If Reply = 2 Then
         '
      Else
         '
      End If
   ElseIf Me.In.Value = Me.Out.Value Then
      '
      If Reply = 2 Then
         '
      Else
         '
      End If
   Else
      If Forms!frmCourseBegin!Private = True Then
         '
      [purple][b]End If
   End If[/b][/purple][/blue]
Compile more often to avert these errors . . .


Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top