Errors only arise in the compiled exe file when accessing Access database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • watson128
    New Member
    • Jun 2006
    • 2

    Errors only arise in the compiled exe file when accessing Access database

    I have a program that interrogates and modifies an Access database. When I run this program from the VB editor it runs fine. When I make the exe file and run that it crashes saying that the "Object invalid or no longer set". Whilst the exe file is in a diferent folder to that of the source, I have made sure I give the full path names to all files I access. Has anyone else had this problem and got any ideas how to fix it. The crash always occurs at a point when it is trying to acces the database (or so it seems).

    I have been trying to fix this for months now but cannot see what he problem is. Like I say it works perfectly until I make the exe file and run that. The section of code which I think is responsible is as follows:
    Code:
    Sub CashUp_Click()
    isoutofstock = False
    For n = 1 To MSFlexGrid2.Rows - 1
        If ProdDetails(n).ProdStock = 0 Then isoutofstock = True
    Next
    If isoutofstock Then Call POrderRaise
    If POraised And MSFlexGrid2.Rows = 1 Then Cancel_Click: Exit Sub
    nextReceiptNumber = GetNextNo(1)
    Set pdb = OpenDatabase(dbName)
    Set p_rec = pdb.OpenRecordset("TillReceipts")
    ...
    I am running VB6 on Windows XP Professional. The database is an Access 2000 database.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    That is a bit of an odd one.

    Are you sure you're specifying full paths and not partial ones? If you're using a partial (or "relative") path, then it will be dependent on the current path, which could change during execution.

    Comment

    • watson128
      New Member
      • Jun 2006
      • 2

      #3
      Originally posted by Killer42
      That is a bit of an odd one.

      Are you sure you're specifying full paths and not partial ones? If you're using a partial (or "relative") path, then it will be dependent on the current path, which could change during execution.
      Hi Killer42

      Thanks for your comment. It is an odd one. However, no I have not fallen for that one. I store a full path name with drive ina global variable. I have even ensured that the exe file is in the same folder as the source files so they are both (the compiled and uncompiled forms) run from the same location.

      Any other ideas?
      Steve

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by watson128
        Thanks for your comment. It is an odd one. However, no I have not fallen for that one. I store a full path name with drive ina global variable. I have even ensured that the exe file is in the same folder as the source files so they are both (the compiled and uncompiled forms) run from the same location.
        Um...

        Not really. It sounds like something related to an ActiveX control, but beyond that I'm stumped.

        You might put in some logging and/or error handling to track down exactly where it's happening. Also, as a debugging thing, I guess you could try switching around your compile options such as P-Code/native, optimisations, upgrade ActiveX, remove info about unused ActiveX, and so on.

        Comment

        Working...