Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / April 2006

Tip: Looking for answers? Try searching our database.

Access crashes while running startup code..

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
every1luvsVB - 11 Apr 2006 04:21 GMT
Hi people,

I wrote a nice little class method that does a dlookup on form_load of the
start up form. basically if the dlookup returns a value, i assign this to the
caption property of the form..

now i built and tested this and it works fine and i have built onto the app
further since over a number of days / development sessions..

NOW all of a sudden, the app decides to crash on startup, giving me the
'Access is sorry to inconvenience you but has to close -do you want to send
an error report.. etc.'

- held the SHIFT key down and tried again, bypassing the startup code and it
opened without a hitch -i then went ahead and commented out all my form_load
code (for the dlookup..) -tried starting app again without the SHIFT key down
and again, it starts without a problem..

Could any of you learned developers tell me what is wrong with my code?? -the
thing that gets me is that it WAS working and NOTHING was changed to cause it
to suddenly not work..

********************************************************
* Here is my class method:
********************************************************
Public Sub loadEnvironment(thisForm As Form, strSpecificCaption As String)
'This subroutine can be called onLoad of each form to add title, logo, etc...
Dim strClubName, strImagePath, strLogoFileName As Variant

strClubName = DLookup("[txtClubName]", "tblEnvironment")
strImagePath = DLookup("[txtImagePath]", "tblEnvironment")
strLogoFileName = DLookup("[txtLogoFileName]", "tblEnvironment")

   'Dynamically load Club Name...
   thisForm.Caption = strClubName & " - Membership Application: " &
strSpecificCaption
   'If form is not datasheet type; and Logo exists, dynamically load Logo...
   If Not (thisForm.DefaultView = 2) Then
       If Not IsNull(strLogoFileName) Then
           thisForm!imgLogoContainer.Picture = strImagePath &
strLogoFileName
       End If
   End If

End Sub

********************************************************
* Here is my form_load call:
********************************************************
On Error GoTo Err_Form_Load

Dim varClubName As Variant
Dim mdlUtils As clsUtilities

  Set mdlUtils = New clsUtilities
  Call mdlUtils.loadEnvironment(Me, "Main Menu")
   
   'If no Club Name value currently exists onLoad of the application,
   'then prompt the user to enter one...
  varClubName = DLookup("[txtClubName]", "tblEnvironment")
   
  If IsNull(varClubName) Then
      Dim WarnMsg As String
      Me!tabctlMainMenu.Pages!pgAdmin.SetFocus
      WarnMsg = "There is currently no Club Name defined for this
application." & vbCrLf & vbCrLf & "Click the 'Administer Environment' button
to enter a new Club Name..."
      MsgBox (WarnMsg)
  End If

Exit_Form_Load:
   Exit Sub

Err_Form_Load:
   MsgBox Err.Description
   Resume Exit_Form_Load
********************************************************
Thanks heaps for any advice!
John Nurick - 11 Apr 2006 06:44 GMT
I'd add some debugging code to create a log file, to make it possible to
discover which line provokes the crash, e.g.

 Open "C:\Temp\DebugLog.txt" For Append As #1
 Write #1, "Starting " & Now()
 
  Set mdlUtils = New clsUtilities
  Write #1 "Set mdlUtils - OK"
  Call mdlUtils.loadEnvironment(Me, "Main Menu")
  Write #1, "Call mdlUtils.loadEnvironment - OK"
   
   'If no Club Name value currently exists onLoad of the application,
   'then prompt the user to enter one...
  varClubName = DLookup("[txtClubName]", "tblEnvironment")
  Write #1, "Dlookup clubname - OK"
   
  ...

After the crash, the last entry in file should show the point reached
before the crash.

>Hi people,
>
[quoted text clipped - 74 lines]
>********************************************************
>Thanks heaps for any advice!

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
every1luvsVB - 15 Apr 2006 08:45 GMT
Hi John,

thankyou for the direction forward. This is a great idea to debug which I did
not really think of..

Well after trying your recommendation, I discovered that my code is working
fine and the actual problem was that I changed the project name in the VB IDE
but then neglected to recompile.. Re-compiling solved the problem.

Cheers.

>I'd add some debugging code to create a log file, to make it possible to
>discover which line provokes the crash, e.g.
John Nurick - 15 Apr 2006 16:48 GMT
That's the great thing about systematic debugging. It helps find the
problem as well as the solution!

>Hi John,
>
[quoted text clipped - 9 lines]
>>I'd add some debugging code to create a log file, to make it possible to
>>discover which line provokes the crash, e.g.

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.