2012-04-06 79 views
1

我創建了作爲epos系統運行的安裝程序中的數據庫。將數據庫導出到其他計算機時的錯誤

在其他計算機上安裝它時,我收到大量的錯誤,都說缺少某些東西。該文件在我的電腦上運行完美,但錯誤停止任何工作在其他電腦上的任何東西....

錯誤如下。每個都有自己的彈出框。

broken reference to excel.exe version 1.7 or missing. 
acwztool.accde missing 
npctrl.dll v4.1 missing 
contactpicker.dll v1.0 missing 
cddbcontolwinamp.dll v1.0 missing 
cddbmusicidwinamp.dll v1.0 missing 
colleagueimport.dll v1.0 missing 
srstsh64.dll missing 

我覺得這可能是因爲我改變了模塊VBA庫引用,這樣我可以運行使用Excel中的VBA代碼,不幸的是我又忘了圖書館的我已經添加

是否有幫助時,我添加的代碼,需要新的引用低於

Public Sub SalesImage_Click() 
Dim rst As ADODB.Recordset 

' Excel object variables 
Dim xlApp As Excel.Application 
Dim xlBook As Excel.Workbook 
Dim xlSheet As Excel.Worksheet 
Dim xlChart As Excel.Chart 

Dim i As Integer 

On Error GoTo HandleErr 

' excel aplication created 
Set xlApp = New Excel.Application 

' workbook created 
Set xlBook = xlApp.Workbooks.Add 

' set so only one worksheet exists 
xlApp.DisplayAlerts = False 
For i = xlBook.Worksheets.Count To 2 Step -1 
    xlBook.Worksheets(i).Delete 
Next i 
xlApp.DisplayAlerts = True 

' reference the first worksheet 
Set xlSheet = xlBook.ActiveSheet 

' naming the worksheet 
xlSheet.name = conSheetName 

' recordset creation 
Set rst = New ADODB.Recordset 
rst.Open _ 
Source:=conQuery, _ 
ActiveConnection:=CurrentProject.Connection 

With xlSheet 
    ' the field names are imported into excel and bolded 
    With .Cells(1, 1) 
     .Value = rst.Fields(0).name 
     .Font.Bold = True 
    End With 
    With .Cells(1, 2) 
     .Value = rst.Fields(1).name 
     .Font.Bold = True 
    End With 

    ' Copy all the data from the recordset into the spreadsheet. 
    .Range("A2").CopyFromRecordset rst 

    ' Format the data the numbering system has been extended to encompas up to 9,999,999 sales to cover all posibilities of sales since the last stock take 
    .Columns(1).AutoFit 
    With .Columns(2) 
     .NumberFormat = "#,###,###" 
     .AutoFit 
    End With 
End With 

' Create the chart. 
Set xlChart = xlApp.Charts.Add 
With xlChart 
    .ChartType = xl3DBarClustered 
    .SetSourceData xlSheet.Cells(1, 1).CurrentRegion 
    .PlotBy = xlColumns 
    .Location _ 
    Where:=xlLocationAsObject, _ 
    name:=conSheetName 
End With 

'the reference must be regotten as it is lost 
With xlBook.ActiveChart 
    .HasTitle = True 
    .HasLegend = False 
    With .ChartTitle 
     .Characters.Text = conSheetName & " Chart" 
     .Font.Size = 16 
     .Shadow = True 
     .Border.LineStyle = xlSolid 
    End With 
    With .ChartGroups(1) 
     .GapWidth = 20 
     .VaryByCategories = True 
    End With 
    .Axes(xlCategory).TickLabels.Font.Size = 8 
    .Axes(xlCategoryScale).TickLabels.Font.Size = 8 
End With 

With xlBook.ActiveChart 
.Axes(xlCategory, xlPrimary).HasTitle = True 
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Product" 
.Axes(xlValue, xlPrimary).HasTitle = True 
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Sales" 
End With 

'format the size and possition of the chart 
With xlBook.ActiveChart 
    .Parent.Width = 800 
    .Parent.Height = 550 
    .Parent.Left = 0 
    .Parent.Top = 0 
End With 

'this displays the chart in excel. excel must be closed by the user to return to the till system 
xlApp.Visible = True 

ExitHere: 
On Error Resume Next 
'this cleans the excel file 
rst.Close 
Set rst = Nothing 
Set xlSheet = Nothing 
Set xlBook = Nothing 
Set xlApp = Nothing 
Exit Sub 

HandleErr: 
MsgBox Err & ": " & Err.Description, , "There has been an error!" 
Resume ExitHere 

End Sub 

回答

2

部署應少麻煩,如果你刪除項目的Excel引用和使用後期綁定的Excel對象。

一個缺點是您在開發期間失去了使用後期綁定的智能感知的好處。但是,在開發期間的早期綁定和後期的生產綁定之間切換非常容易。只需更改編譯器常量的值即可。

在模塊的聲明節...

#Const DevStatus = "PROD" 'PROD or DEV 

然後一個過程的體內......

#If DevStatus = "DEV" Then 
     Dim xlApp As Excel.Application 
     Dim xlBook As Excel.Workbook 
     Dim xlSheet As Excel.Worksheet 
     Set xlApp = New Excel.Application 
    #Else ' assume PROD (actually anything other than DEV) 
     Dim xlApp As Object 
     Dim xlBook As Object 
     Dim xlSheet As Object 
     Set xlApp = CreateObject("Excel.Application") 
    #End If 

隨着後期綁定您的代碼將需要使用Excel常量的值而不是常量名稱。或者,您可以在#Else塊中定義命名常量以供生產使用,然後在代碼中繼續按名稱使用它們。

我不知道那些其他參考是什麼。建議您帶一份項目副本,刪除所有這些參考資料,並查看從VB編輯器主菜單運行Debug->Compile時會發生什麼。不要選中任何不需要的引用。並嘗試晚結合其餘的。在Access應用程序的生產版本中,我只使用3個引用:VBA;訪問;和DAO。

+0

非常感謝您的回答,我很恐慌,因爲我必須在幾周內交付。 你知道我在哪裏可以獲得訪問中包含的基準參考列表。我正在考慮重新安裝訪問權限,因爲我想它會重置庫引用並從那裏開始工作。明天當我有時間看時,我會試試這個。 – 2012-04-07 17:57:05

+1

重新安裝Access應該不需要進行排序。創建一個新的數據庫,看看你得到哪些參考。除了我提到的3之外,你可能會得到OLE自動化;我沒有選中那個,也沒有注意到任何問題。如果您使用Access 2007創建新的ACCDB格式數據庫,則將獲得Access數據庫引擎庫而不是DAO。如果您的學校Access版本是2003或更早的版本,那麼參考差異不應該成爲問題,因爲這些較舊的Access版本首先無法應對ACCDB。 – HansUp 2012-04-07 19:22:33

+1

我希望回覆令人滿意。我試圖鼓勵你爲自己保持簡單。如果您想了解更多詳細信息,請參閱Access MVP Doug Steele關於該主題的說明:http://www.accessmvp.com/djsteele/accessreferenceerrors.html – HansUp 2012-04-07 19:26:11