achen30
asked on
Compile error: Error in loading dll
The following source code are in VB6, and trying to access to Microsoft DB (.mdb) file. The code failed on .Recordset.BOF, I got the error message: "Error in loading dll".
Source code:
With startform
.datLocalQueue.Refresh
If .datLocalQueue.Recordset.B
numLocalQueueRecords = 0
Else
.datLocalQueue.Recordset.M
numLocalQueueRecords = .datLocalQueue.Recordset.r
End If
End With
I tried to fix it last time, I copied the DAO350.dll from another PC, it works fine last week. For some reason, it failed again. I did search on this topic, it suggest me to uninstall Microsoft office 2000 Professional and reinstall it, I did that, I still have the problem.
Can someone suggest something else for me to try it?
Thanks
ASKER
I installed Microsoft Visual Studio 2005 source safe last week. I'm not sure if that caused the problem with the dlls since they all Microsoft product.
I'm using DAO and connect to Access Database. The Access Database was built on Microsoft Access 97, but the version that I have on my local pc is Microsft Access 2000. Do you know if that will cause any problem? I didn't have that problem last time.
Thanks,
Annie
I'm using DAO and connect to Access Database. The Access Database was built on Microsoft Access 97, but the version that I have on my local pc is Microsft Access 2000. Do you know if that will cause any problem? I didn't have that problem last time.
Thanks,
Annie
No. That is what I have on my computer right now VS.Net, VB6, Access97 and well as Access2000. All working fine. Let me find something and get back to you.
ASKER
Thank you very much for your help!
This is what I could find.
http://www.microsoft.com/downloads/details.aspx?FamilyID=c57692e9-dde7-4a60-b586-5d4fd6794db6&DisplayLang=en
I believe if we go any higher in version (2.6 or newer), it will not work because they discontinue the DAO.
http://www.microsoft.com/downloads/details.aspx?FamilyID=c57692e9-dde7-4a60-b586-5d4fd6794db6&DisplayLang=en
I believe if we go any higher in version (2.6 or newer), it will not work because they discontinue the DAO.
I am hoping the MDAC 2.5 will install or fix the dll. If it happens again then something is messing with the dll and it is not the VS.Net or Access 2000.
ASKER
I download the MDAC2.5, but it won't let me install it. I got Fetal Setup error, asked to readup about it before I install it. It's very confusing.
One thing you should note that if the db is corrupted in certain way, it could generate the same error. Were you able to open it in Access 97 and try to compact it? It just seems odd that it would generate the dll error on .bof. Usually it will generate the error as soon as it tries to connect.
Did you open the mdb in Access 2000 and click on convert? If so then you need to convert it back to Access97 or use DAO 3.6.
Did you open the mdb in Access 2000 and click on convert? If so then you need to convert it back to Access97 or use DAO 3.6.
ASKER
I also install the Jet 3.51SP3 version, would that be problem?
No. I did that as well. This is why I want you to check your mdb to make sure it is not corrupted or in Access 2000 format.
ASKER
The .mdb file was built in Access 97. The file is not corrupted. I can view on Access 2000, but I got the warning message everytime I open the .mdb file, it says You can't make changes to the database object in the database, the database was created in an earlier version of Microsoft Access.
I also download the componet checker on my pc, I have the MDAC 2.1, all the 2.5 - 2.8 version.
I also download the componet checker on my pc, I have the MDAC 2.1, all the 2.5 - 2.8 version.
Is that line with bof the only time it gives you this error?
With startform
.datLocalQueue.Refresh
If .datLocalQueue.Recordset.B OF And .datLocalQueue.Recordset.E OF Then 'no records
numLocalQueueRecords = 0
Else
.datLocalQueue.Recordset.M oveLast
numLocalQueueRecords = .datLocalQueue.Recordset.r ecordcount
End If
End With
With startform
.datLocalQueue.Refresh
If .datLocalQueue.Recordset.B
numLocalQueueRecords = 0
Else
.datLocalQueue.Recordset.M
numLocalQueueRecords = .datLocalQueue.Recordset.r
End If
End With
send to soon.
try this.
With startform
.datLocalQueue.Refresh
If .datLocalQueue.Recordset. = 0 Then 'no records
numLocalQueueRecords = 0
Else
.datLocalQueue.Recordset.M oveLast
numLocalQueueRecords = .datLocalQueue.Recordset.r ecordcount
End If
End With
try this.
With startform
.datLocalQueue.Refresh
If .datLocalQueue.Recordset. = 0 Then 'no records
numLocalQueueRecords = 0
Else
.datLocalQueue.Recordset.M
numLocalQueueRecords = .datLocalQueue.Recordset.r
End If
End With
ASKER
same error message on .Recordset (error in loading file.)
With startform
.datLocalQueue.Refresh
'If .datLocalQueue.Recordset.B
If .datLocalQueue.Recordset = 0 Then
numLocalQueueRecords = 0
Else
.datLocalQueue.Recordset.M
numLocalQueueRecords = .datLocalQueue.Recordset.r
End If
End With
Is that the only place you get the RTE?
ASKER
The DAO350.dll has file version of 3.51.1608.0, dated on 4/27/1998. Is that right one? Is there reference file to this DAO350.dll?
Same as mine.
ASKER
It failed anyway that is reference to data.recordset, there's no function show up on .recoredset, suce as .eof, .bof, .moveFirst, .moveLast, .and .FindFirst. All those function/method that belongs recordset.
Are you saying that VB6 will not bring up a list if you do this
rs. >>> should pop up a lists.
?
rs. >>> should pop up a lists.
?
ASKER
that's right, nothing is on the pop up list if I do startform.datLocalQueue.re cordset. . So i know it's probelm with my DAO350.dll file. Because none of the properties or methods that belongs to recordset won't show up.
OK. How did you declare it? If you did not declare it right, the reference list will not appear and it could also generate the error. Did you just added ADO as your reference and if so then you may need to prefix like below.
Dim db As dao.Database
Dim rs As dao.Recordset
Dim db As dao.Database
Dim rs As dao.Recordset
ASKER
I didn't know that. Yes, I just added new reference Microsoft ADO 2.7 on this project, because there's one of part of the function, I need to save the data to SQL Database. But the other part of the function I didn't need to, so it stays in Access Database.
Ok, my program use the Data Control to link to Access Database, the datLocalQueue is data control, I don't see anyway in the code to specify or declare recordset. Is that part of Data Control properties?
Ok, my program use the Data Control to link to Access Database, the datLocalQueue is data control, I don't see anyway in the code to specify or declare recordset. Is that part of Data Control properties?
ASKER
I'm not familiar with DAO at all. Your help and patient will be greatly appreciated.
There's source code as follows:
startform.datLocalQueue.Da tabaseName = localQueueDB 'localQueueDB is string which is equal to Access .mdb file name c:\Temp\test.mdb.
I don't see anywhere that I can specify DAO.database or DAO.Recordset.
There's source code as follows:
startform.datLocalQueue.Da
I don't see anywhere that I can specify DAO.database or DAO.Recordset.
Its in the declare section. There you want to add dao or adodb to database or recordset.
right now you may have this
dim datLocalQueue as recordset.
change it to this.
dim datLocalQueue as dao.recordset.
right now you may have this
dim datLocalQueue as recordset.
change it to this.
dim datLocalQueue as dao.recordset.
Is this code below for ADO (for sql server) if not then disregard this.
.datLocalQueue.Refresh
'If .datLocalQueue.Recordset.B
If .datLocalQueue.Recordset = 0 Then
numLocalQueueRecords = 0
Else
.datLocalQueue.Recordset.M
numLocalQueueRecords = .datLocalQueue.Recordset.r
End If
End With
If so then do this.
Set conn = New adodb.Connection
Set rsConn = New adodb.Recordset
The order of reference affects this so if you have ADO listed under DAO then you must prefix it with adodb as vise versa same it DAO. The order is determine by Project > Reference. That is why there is a move and down button for priority.
When did you add ADO 2.7? Did you add it and about the same time you have this problem? If so then comment it out and de-reference it to test it. If it works then recheck the ADO reference and make sure it is on the bottom
ASKER
The above source code is for DAO. I unselected Microsoft ADO 2.7 refererence for now, and comment out my source code, just try to run project like was working before, it still doesnot work. I even close the close project and open the project again. I don't have any luck. Like I said, there's no place in the source code that you can specified DAO database or DAO recordset, it used the Data Control.
ASKER
Is Data control only for DAO Microsoft Jet Database only? So I don't think we need to specify with the ADO or DAO anymore... is that assumption right? Like I said, I'm not familiar with DAO or Data control at all.
But it still doesn't show up any properties or method on .recordset.
Thanks for your help,
annie
But it still doesn't show up any properties or method on .recordset.
Thanks for your help,
annie
ASKER
I wrote some simple code, and did the test, the following function worked. But my Data Control still doesn't work.
Private Function testMe()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = OpenDatabase(defaultLocalQ ueueDB)
Set rs = db.OpenRecordset("LocalQue ue", dbOpenDynaset)
If rs.EOF Or rs.BOF Then
MsgBox "Test on eof or bof."
Else
MsgBox "test 1."
End If
End Function
Private Function testMe()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = OpenDatabase(defaultLocalQ
Set rs = db.OpenRecordset("LocalQue
If rs.EOF Or rs.BOF Then
MsgBox "Test on eof or bof."
Else
MsgBox "test 1."
End If
End Function
There is a property for datacontrol and it should be set to access. I forget the name of it but I think it is database.
ASKER
The property is called Connect, and it's already set to Access.
Good morning shall we try round two now. LOL.
I do not use data bound control because they cause problems for large network users. I am trying to think what else we should check. I seriously doubt anything is wrong with your DLL at all. It’s either your code or a bug in the data control that you are using. Could you post the whole routine for this data control?
I do not use data bound control because they cause problems for large network users. I am trying to think what else we should check. I seriously doubt anything is wrong with your DLL at all. It’s either your code or a bug in the data control that you are using. Could you post the whole routine for this data control?
ASKER
yes, thank you. Let's try again today ;-)
I tried to copy the source code as little as I can (still a lot...) I don't know how to copy data control property settings.
Private Sub Form_Load()
Dim recordcount As Integer
Dim msgReply As String
Dim test As Boolean
Dim backupTest As String
Dim captionString As String
Dim i As Integer
On Error GoTo formLoadError
testMe
Screen.MousePointer = vbHourglass
captionString = App.Title
If App.PrevInstance Then
MsgBox captionString & " is already running on this machine. A second instance can not be started.", vbCritical, "Application Already Running"
AppActivate captionString
End
End If
startform.Caption = captionString
If Not doApplicationSettings Then
MsgBox "Error while setting up application in function doApplicationSettings. Application can not continue.", vbCritical, "Application Settings Error"
End
End If
backupTest = Dir(networkDBPath & "\", vbNormal)
If Len(backupTest) > 0 Then
FileCopy setupDB, backupPath & "HLD2SETUP.mdb"
End If
'position start screen in center horizontally and
'and center vertically when in tall mode
startform.top = (Screen.Height - Tall) \ 2
startform.Left = (Screen.Width \ 2) - (startform.Width \ 2)
datLocalQueue.Refresh
datNetworkQueue.Refresh
datLocalArchive.Refresh
dataString = ""
transmissionErrorMsg = False
transmissionError = False
txtDataWindow.Text = ""
txtPlateNumber.Text = ""
txtLength.Text = ""
txtDiameter.Text = ""
lblStatus.Caption = "Idle"
'test if any data in local queue. should normally be empty
'it failed in here
recordcount = numLocalQueueRecords
If recordcount > 0 Then
msgReply = MsgBox("Unsaved records were found in the queue. " & _
"This typically will happen if the application or computer crashes prior to saving. " & _
"Do you want to save these records now? " & _
"If you choose no, these records will be deleted.", vbYesNo, "Unsaved Records Found")
If msgReply = vbNo Then
boolNeedTosave = False
clearLocalQueue
Else
boolNeedTosave = True
lblLocalQueueCount.Caption = recordcount
End If
Else
lblLocalQueueCount.Caption = 0
End If
Screen.MousePointer = 0
Exit Sub
formLoadError:
Select Case Err.Number
'if error saving setup database then application will continue
'else the application ends if error loading startform.
Case 52, 53, 55, 57, 58, 61, 67, 70, 71, 75, 76
MsgBox "Setup database backup failed. Please inform your supervisor.", vbCritical
Resume Next
Case Else
Call ErrorHandler(Me.Name, "Form_Load", Err.Source, Err.Number, Err.Description)
MsgBox "Error loading startup form. Application will end.", vbCritical, "StartForm Load Error"
End Select
End
End Sub
Public Function numLocalQueueRecords() As Integer
With startform
.datLocalQueue.Refresh
If .datLocalQueue.Recordset.B OF And .datLocalQueue.Recordset.E OF Then 'no records
If rs.BOF And rs.EOF Then 'no records
numLocalQueueRecords = 0
Else
.datLocalQueue.Recordset.M oveLast
numLocalQueueRecords = .datLocalQueue.Recordset.r ecordcount
End If
End With
End Function
Public Function doApplicationSettings() As Boolean
Dim retSetting As String
Dim retNetworkDBPath As String
On Error GoTo doApplicationSettingsError
'retrieve database locations from registry
'if no entry found then the default location is saved to the registry
'and the default location is used.
'test to be sure all local database files exist
'if local database missing see if backup exists on network
'if backup exists copy to local, delete associated ldb if exists.
'write to error file if have to copy network db's
'test network and password database but dont terminate if not found
'************ Error File
retSetting = GetSetting(App.Title, "Database Locations", "Error File")
If retSetting = "" Then
SaveSetting App.Title, "Database Locations", "Error File", defaultErrorFile
errorFile = defaultErrorFile
Else
errorFile = retSetting
End If
'************** networkDB
'foxpro takes path as databaseName and filename w/o .dbf for datasource
'path
retSetting = GetSetting(App.Title, "Database Locations", "Network DB Path")
If retSetting = "" Then
networkDBPath = defaultNetworkDBPath
networkDBName = defaultNetworkDBName
SaveSetting App.Title, "Database Locations", "Network DB Path", networkDBPath
SaveSetting App.Title, "Database Locations", "Network DB Name", networkDBName
Else
networkDBPath = retSetting
'filename
retSetting = GetSetting(App.Title, "Database Locations", "Network DB Name")
If retSetting = "" Then
networkDBPath = defaultNetworkDBPath
networkDBName = defaultNetworkDBName
SaveSetting App.Title, "Database Locations", "Network DB Path", networkDBPath
SaveSetting App.Title, "Database Locations", "Network DB Name", networkDBName
Else
networkDBName = retSetting
End If
End If
If Not fileExists(networkDBPath & "\" & networkDBName & ".dbf") Then
errMsg = "Could not find file " & networkDBPath & "\" & networkDBName & ".dbf" & ". Program will not be able to save to the network. All data will be saved locally"
MsgBox errMsg, vbExclamation, "Database File Error"
writeError (errMsg)
End If
'*****************
backupPath = networkDBPath & "\HLD2BAK\"
'*********** setupDB
retSetting = GetSetting(App.Title, "Database Locations", "Set up DB")
If retSetting = "" Then
setupDB = defaultSetupDB
SaveSetting App.Title, "Database Locations", "Set up DB", setupDB
Else
setupDB = retSetting
End If
If Not fileExists(setupDB) Then
If fileExists(backupPath & "HLD2SETUP.MDB") Then
FileCopy backupPath & "HLD2SETUP.MDB", setupDB
If fileExists(stringPath(setu pDB) & "\HLD2SETUP.ldb") Then
Kill stringPath(setupDB) & "\HLD2SETUP.ldb"
End If
writeError ("Setup db missing and copied from network")
Else
errMsg = "Could not find file '" & setupDB & "' for set up database. Program will terminate."
MsgBox errMsg, vbCritical, "Database File Error"
writeError (errMsg)
End
End If
End If
startform.datProcess.Datab aseName = setupDB
startform.datOperator.Data baseName = setupDB
startform.datRecentResist. DatabaseNa me = setupDB
'************ localQueueDB
retSetting = GetSetting(App.Title, "Database Locations", "Local Queue DB")
If retSetting = "" Then
localQueueDB = defaultLocalQueueDB
SaveSetting App.Title, "Database Locations", "Local Queue DB", localQueueDB
Else
localQueueDB = retSetting
End If
If Not fileExists(localQueueDB) Then
If fileExists(backupPath & "local2Queue.MDB") Then
FileCopy backupPath & "local2Queue.MDB", localQueueDB
If fileExists(stringPath(loca lQueueDB) & "\local2Queue.ldb") Then
Kill stringPath(localQueueDB) & "\local2Queue.ldb"
End If
writeError ("localQueue DB missing and copied from network")
Else
errMsg = "Could not find file " & localQueueDB & ". Program will terminate."
MsgBox errMsg, vbCritical, "Database File Error"
writeError (errMsg)
End
End If
End If
startform.datLocalQueue.Da tabaseName = localQueueDB
'************* networkQueueDB
retSetting = GetSetting(App.Title, "Database Locations", "Network Queue DB")
If retSetting = "" Then
networkQueueDB = defaultNetworkQueueDB
SaveSetting App.Title, "Database Locations", "Network Queue DB", networkQueueDB
Else
networkQueueDB = retSetting
End If
If Not fileExists(networkQueueDB) Then
If fileExists(backupPath & "network2Queue.MDB") Then
FileCopy backupPath & "network2Queue.MDB", networkQueueDB
If fileExists(stringPath(netw orkQueueDB ) & "\network2Queue.ldb") Then
Kill stringPath(networkQueueDB) & "\network2Queue.ldb"
End If
writeError ("network2Queue DB missing and copied from network")
Else
errMsg = "Could not find file " & networkQueueDB & ". Program will terminate."
MsgBox errMsg, vbCritical, "Database File Error"
writeError (errMsg)
End
End If
End If
startform.datNetworkQueue. DatabaseNa me = networkQueueDB
'************** localArchiveDB
retSetting = GetSetting(App.Title, "Database Locations", "Local Archive DB")
If retSetting = "" Then
localArchiveDB = defaultLocalArchiveDB
SaveSetting App.Title, "Database Locations", "Local Archive DB", localArchiveDB
Else
localArchiveDB = retSetting
End If
If Not fileExists(localArchiveDB) Then
If fileExists(backupPath & "local2Archive.MDB") Then
FileCopy backupPath & "local2Archive.MDB", localArchiveDB
If fileExists(stringPath(loca lArchiveDB ) & "\local2Archive.ldb") Then
Kill stringPath(localArchiveDB) & "\local2Archive.ldb"
End If
writeError ("localArchive DB missing and copied from network")
Else
errMsg = "Could not find file " & localArchiveDB & ". Program will terminate."
MsgBox errMsg, vbCritical, "Database File Error"
writeError (errMsg)
End
End If
End If
startform.datLocalArchive. DatabaseNa me = localArchiveDB
'************* passwordDB
retSetting = GetSetting(App.Title, "Database Locations", "Password DB")
If retSetting = "" Then
passwordDB = defaultPasswordDB
SaveSetting App.Title, "Database Locations", "Password DB", passwordDB
Else
passwordDB = retSetting
End If
If Not fileExists(passwordDB) Then
errMsg = "Could not find file " & passwordDB & ". You will not be able to enter set up."
MsgBox errMsg, vbExclamation, "Database File Error"
End If
'******* number to save in chrome and resist lot pick lists
retSetting = GetSetting(App.Title, "Preferences", "Number Recent Chrome")
If retSetting = "" Or Not IsNumeric(retSetting) Then
numRecentChrome = 6
SaveSetting App.Title, "Preferences", "Number Recent Chrome", numRecentChrome
Else
numRecentChrome = CInt(retSetting)
End If
'retSetting = GetSetting(App.Title, "Preferences", "Number Recent Resist")
'If retSetting = "" Or Not IsNumeric(retSetting) Then
' numRecentResist = 6
' SaveSetting App.Title, "Preferences", "Number Recent Resist", numRecentResist
'Else
' numRecentResist = CInt(retSetting)
'End If
retSetting = GetSetting(App.Title, "Preferences", "Machine")
If retSetting = "" Or Not IsNumeric(retSetting) Then
intCurrentMachine = 2
SaveSetting App.Title, "Preferences", "Machine", intCurrentMachine
Else
intCurrentMachine = CInt(retSetting)
End If
'******* Communications
'comm port
retSetting = GetSetting(App.Title, "Communications", "Comm Port")
If retSetting = "" Or Not IsNumeric(retSetting) Then
startform.MSComm1.CommPort = 1
SaveSetting App.Title, "Communications", "Comm Port", startform.MSComm1.CommPort
Else
startform.MSComm1.CommPort = CInt(retSetting)
End If
'handshaking
retSetting = GetSetting(App.Title, "Communications", "Handshaking")
If retSetting = "" Or Not IsNumeric(retSetting) Then
startform.MSComm1.Handshak ing = 0
SaveSetting App.Title, "Communications", "Handshaking", startform.MSComm1.Handshak ing
Else
startform.MSComm1.Handshak ing = CInt(retSetting)
End If
'inBufferSize
retSetting = GetSetting(App.Title, "Communications", "Input Buffer")
If retSetting = "" Or Not IsNumeric(retSetting) Then
startform.MSComm1.InBuffer Size = 2048
SaveSetting App.Title, "Communications", "Input Buffer", startform.MSComm1.InBuffer Size
Else
startform.MSComm1.InBuffer Size = CInt(retSetting)
End If
'DTREnable
retSetting = GetSetting(App.Title, "Communications", "DTR Enable")
If retSetting <> "True" Or retSetting <> "False" Then
startform.MSComm1.DTREnabl e = True
SaveSetting App.Title, "Communications", "DTR Enable", startform.MSComm1.DTREnabl e
Else
startform.MSComm1.DTREnabl e = retSetting
End If
'RTSEnable
retSetting = GetSetting(App.Title, "Communications", "RTS Enable")
If retSetting <> "True" Or retSetting <> "False" Then
startform.MSComm1.RTSEnabl e = False
SaveSetting App.Title, "Communications", "RTS Enable", startform.MSComm1.RTSEnabl e
Else
startform.MSComm1.RTSEnabl e = retSetting
End If
'settings
retSetting = GetSetting(App.Title, "Communications", "Settings")
If retSetting = "" Then
startform.MSComm1.Settings = "9600,n,8,1"
SaveSetting App.Title, "Communications", "Settings", startform.MSComm1.Settings
Else
startform.MSComm1.Settings = retSetting
End If
'tmrBufferPoll
retSetting = GetSetting(App.Title, "Communications", "Buffer Poll (ms)")
If retSetting = "" Or Not IsNumeric(retSetting) Then
startform.tmrBufferPoll.In terval = 800
SaveSetting App.Title, "Communications", "Buffer Poll (ms)", startform.tmrBufferPoll.In terval
Else
startform.tmrBufferPoll.In terval = CInt(retSetting)
End If
'************ Network
'Retry minutes
retSetting = GetSetting(App.Title, "Network", "Retry (min)")
If retSetting = "" Or Not IsNumeric(retSetting) Then
networkTryMinutes = 15
SaveSetting App.Title, "Network", "Retry (min)", networkTryMinutes
Else
networkTryMinutes = CInt(retSetting)
End If
'************************
doApplicationSettings = True
Exit Function
doApplicationSettingsError :
Call ErrorHandler("AppSettings module", "doApplicationSettings", Err.Source, Err.Number, Err.Description)
doApplicationSettings = False
End Function
'default database locations
Public Const defaultSetupDB$ = "C:\Program Files\HLD2 Data Capture\HLD2SETUP.MDB"
Public Const defaultLocalQueueDB$ = "C:\Program Files\HLD2 Data Capture\local2Queue.mdb"
Public Const defaultNetworkQueueDB$ = "C:\Program Files\HLD2 Data Capture\network2Queue.mdb"
Public Const defaultLocalArchiveDB$ = "C:\Program Files\HLD2 Data Capture\local2Archive.mdb"
Public Const defaultErrorFile$ = "C:\Program Files\HLD2 Data Capture\HLD2Errors.txt"
Public Const defaultPasswordDB$ = "\\Suspous0020\departments \Productio n\readwrit e\eqlog\do wntime.mdb " ' "C:\Program Files\HLD2 Data Capture\downtime.mdb"
Public Const defaultNetworkDBPath$ = "\\Suspous0020\departments \Productio n\readwrit e\HLD2" ' "C:\Program Files\HLD2 Data Capture"
Public Const defaultNetworkDBName$ = "hld2net"
I tried to copy the source code as little as I can (still a lot...) I don't know how to copy data control property settings.
Private Sub Form_Load()
Dim recordcount As Integer
Dim msgReply As String
Dim test As Boolean
Dim backupTest As String
Dim captionString As String
Dim i As Integer
On Error GoTo formLoadError
testMe
Screen.MousePointer = vbHourglass
captionString = App.Title
If App.PrevInstance Then
MsgBox captionString & " is already running on this machine. A second instance can not be started.", vbCritical, "Application Already Running"
AppActivate captionString
End
End If
startform.Caption = captionString
If Not doApplicationSettings Then
MsgBox "Error while setting up application in function doApplicationSettings. Application can not continue.", vbCritical, "Application Settings Error"
End
End If
backupTest = Dir(networkDBPath & "\", vbNormal)
If Len(backupTest) > 0 Then
FileCopy setupDB, backupPath & "HLD2SETUP.mdb"
End If
'position start screen in center horizontally and
'and center vertically when in tall mode
startform.top = (Screen.Height - Tall) \ 2
startform.Left = (Screen.Width \ 2) - (startform.Width \ 2)
datLocalQueue.Refresh
datNetworkQueue.Refresh
datLocalArchive.Refresh
dataString = ""
transmissionErrorMsg = False
transmissionError = False
txtDataWindow.Text = ""
txtPlateNumber.Text = ""
txtLength.Text = ""
txtDiameter.Text = ""
lblStatus.Caption = "Idle"
'test if any data in local queue. should normally be empty
'it failed in here
recordcount = numLocalQueueRecords
If recordcount > 0 Then
msgReply = MsgBox("Unsaved records were found in the queue. " & _
"This typically will happen if the application or computer crashes prior to saving. " & _
"Do you want to save these records now? " & _
"If you choose no, these records will be deleted.", vbYesNo, "Unsaved Records Found")
If msgReply = vbNo Then
boolNeedTosave = False
clearLocalQueue
Else
boolNeedTosave = True
lblLocalQueueCount.Caption
End If
Else
lblLocalQueueCount.Caption
End If
Screen.MousePointer = 0
Exit Sub
formLoadError:
Select Case Err.Number
'if error saving setup database then application will continue
'else the application ends if error loading startform.
Case 52, 53, 55, 57, 58, 61, 67, 70, 71, 75, 76
MsgBox "Setup database backup failed. Please inform your supervisor.", vbCritical
Resume Next
Case Else
Call ErrorHandler(Me.Name, "Form_Load", Err.Source, Err.Number, Err.Description)
MsgBox "Error loading startup form. Application will end.", vbCritical, "StartForm Load Error"
End Select
End
End Sub
Public Function numLocalQueueRecords() As Integer
With startform
.datLocalQueue.Refresh
If .datLocalQueue.Recordset.B
If rs.BOF And rs.EOF Then 'no records
numLocalQueueRecords = 0
Else
.datLocalQueue.Recordset.M
numLocalQueueRecords = .datLocalQueue.Recordset.r
End If
End With
End Function
Public Function doApplicationSettings() As Boolean
Dim retSetting As String
Dim retNetworkDBPath As String
On Error GoTo doApplicationSettingsError
'retrieve database locations from registry
'if no entry found then the default location is saved to the registry
'and the default location is used.
'test to be sure all local database files exist
'if local database missing see if backup exists on network
'if backup exists copy to local, delete associated ldb if exists.
'write to error file if have to copy network db's
'test network and password database but dont terminate if not found
'************ Error File
retSetting = GetSetting(App.Title, "Database Locations", "Error File")
If retSetting = "" Then
SaveSetting App.Title, "Database Locations", "Error File", defaultErrorFile
errorFile = defaultErrorFile
Else
errorFile = retSetting
End If
'************** networkDB
'foxpro takes path as databaseName and filename w/o .dbf for datasource
'path
retSetting = GetSetting(App.Title, "Database Locations", "Network DB Path")
If retSetting = "" Then
networkDBPath = defaultNetworkDBPath
networkDBName = defaultNetworkDBName
SaveSetting App.Title, "Database Locations", "Network DB Path", networkDBPath
SaveSetting App.Title, "Database Locations", "Network DB Name", networkDBName
Else
networkDBPath = retSetting
'filename
retSetting = GetSetting(App.Title, "Database Locations", "Network DB Name")
If retSetting = "" Then
networkDBPath = defaultNetworkDBPath
networkDBName = defaultNetworkDBName
SaveSetting App.Title, "Database Locations", "Network DB Path", networkDBPath
SaveSetting App.Title, "Database Locations", "Network DB Name", networkDBName
Else
networkDBName = retSetting
End If
End If
If Not fileExists(networkDBPath & "\" & networkDBName & ".dbf") Then
errMsg = "Could not find file " & networkDBPath & "\" & networkDBName & ".dbf" & ". Program will not be able to save to the network. All data will be saved locally"
MsgBox errMsg, vbExclamation, "Database File Error"
writeError (errMsg)
End If
'*****************
backupPath = networkDBPath & "\HLD2BAK\"
'*********** setupDB
retSetting = GetSetting(App.Title, "Database Locations", "Set up DB")
If retSetting = "" Then
setupDB = defaultSetupDB
SaveSetting App.Title, "Database Locations", "Set up DB", setupDB
Else
setupDB = retSetting
End If
If Not fileExists(setupDB) Then
If fileExists(backupPath & "HLD2SETUP.MDB") Then
FileCopy backupPath & "HLD2SETUP.MDB", setupDB
If fileExists(stringPath(setu
Kill stringPath(setupDB) & "\HLD2SETUP.ldb"
End If
writeError ("Setup db missing and copied from network")
Else
errMsg = "Could not find file '" & setupDB & "' for set up database. Program will terminate."
MsgBox errMsg, vbCritical, "Database File Error"
writeError (errMsg)
End
End If
End If
startform.datProcess.Datab
startform.datOperator.Data
startform.datRecentResist.
'************ localQueueDB
retSetting = GetSetting(App.Title, "Database Locations", "Local Queue DB")
If retSetting = "" Then
localQueueDB = defaultLocalQueueDB
SaveSetting App.Title, "Database Locations", "Local Queue DB", localQueueDB
Else
localQueueDB = retSetting
End If
If Not fileExists(localQueueDB) Then
If fileExists(backupPath & "local2Queue.MDB") Then
FileCopy backupPath & "local2Queue.MDB", localQueueDB
If fileExists(stringPath(loca
Kill stringPath(localQueueDB) & "\local2Queue.ldb"
End If
writeError ("localQueue DB missing and copied from network")
Else
errMsg = "Could not find file " & localQueueDB & ". Program will terminate."
MsgBox errMsg, vbCritical, "Database File Error"
writeError (errMsg)
End
End If
End If
startform.datLocalQueue.Da
'************* networkQueueDB
retSetting = GetSetting(App.Title, "Database Locations", "Network Queue DB")
If retSetting = "" Then
networkQueueDB = defaultNetworkQueueDB
SaveSetting App.Title, "Database Locations", "Network Queue DB", networkQueueDB
Else
networkQueueDB = retSetting
End If
If Not fileExists(networkQueueDB)
If fileExists(backupPath & "network2Queue.MDB") Then
FileCopy backupPath & "network2Queue.MDB", networkQueueDB
If fileExists(stringPath(netw
Kill stringPath(networkQueueDB)
End If
writeError ("network2Queue DB missing and copied from network")
Else
errMsg = "Could not find file " & networkQueueDB & ". Program will terminate."
MsgBox errMsg, vbCritical, "Database File Error"
writeError (errMsg)
End
End If
End If
startform.datNetworkQueue.
'************** localArchiveDB
retSetting = GetSetting(App.Title, "Database Locations", "Local Archive DB")
If retSetting = "" Then
localArchiveDB = defaultLocalArchiveDB
SaveSetting App.Title, "Database Locations", "Local Archive DB", localArchiveDB
Else
localArchiveDB = retSetting
End If
If Not fileExists(localArchiveDB)
If fileExists(backupPath & "local2Archive.MDB") Then
FileCopy backupPath & "local2Archive.MDB", localArchiveDB
If fileExists(stringPath(loca
Kill stringPath(localArchiveDB)
End If
writeError ("localArchive DB missing and copied from network")
Else
errMsg = "Could not find file " & localArchiveDB & ". Program will terminate."
MsgBox errMsg, vbCritical, "Database File Error"
writeError (errMsg)
End
End If
End If
startform.datLocalArchive.
'************* passwordDB
retSetting = GetSetting(App.Title, "Database Locations", "Password DB")
If retSetting = "" Then
passwordDB = defaultPasswordDB
SaveSetting App.Title, "Database Locations", "Password DB", passwordDB
Else
passwordDB = retSetting
End If
If Not fileExists(passwordDB) Then
errMsg = "Could not find file " & passwordDB & ". You will not be able to enter set up."
MsgBox errMsg, vbExclamation, "Database File Error"
End If
'******* number to save in chrome and resist lot pick lists
retSetting = GetSetting(App.Title, "Preferences", "Number Recent Chrome")
If retSetting = "" Or Not IsNumeric(retSetting) Then
numRecentChrome = 6
SaveSetting App.Title, "Preferences", "Number Recent Chrome", numRecentChrome
Else
numRecentChrome = CInt(retSetting)
End If
'retSetting = GetSetting(App.Title, "Preferences", "Number Recent Resist")
'If retSetting = "" Or Not IsNumeric(retSetting) Then
' numRecentResist = 6
' SaveSetting App.Title, "Preferences", "Number Recent Resist", numRecentResist
'Else
' numRecentResist = CInt(retSetting)
'End If
retSetting = GetSetting(App.Title, "Preferences", "Machine")
If retSetting = "" Or Not IsNumeric(retSetting) Then
intCurrentMachine = 2
SaveSetting App.Title, "Preferences", "Machine", intCurrentMachine
Else
intCurrentMachine = CInt(retSetting)
End If
'******* Communications
'comm port
retSetting = GetSetting(App.Title, "Communications", "Comm Port")
If retSetting = "" Or Not IsNumeric(retSetting) Then
startform.MSComm1.CommPort
SaveSetting App.Title, "Communications", "Comm Port", startform.MSComm1.CommPort
Else
startform.MSComm1.CommPort
End If
'handshaking
retSetting = GetSetting(App.Title, "Communications", "Handshaking")
If retSetting = "" Or Not IsNumeric(retSetting) Then
startform.MSComm1.Handshak
SaveSetting App.Title, "Communications", "Handshaking", startform.MSComm1.Handshak
Else
startform.MSComm1.Handshak
End If
'inBufferSize
retSetting = GetSetting(App.Title, "Communications", "Input Buffer")
If retSetting = "" Or Not IsNumeric(retSetting) Then
startform.MSComm1.InBuffer
SaveSetting App.Title, "Communications", "Input Buffer", startform.MSComm1.InBuffer
Else
startform.MSComm1.InBuffer
End If
'DTREnable
retSetting = GetSetting(App.Title, "Communications", "DTR Enable")
If retSetting <> "True" Or retSetting <> "False" Then
startform.MSComm1.DTREnabl
SaveSetting App.Title, "Communications", "DTR Enable", startform.MSComm1.DTREnabl
Else
startform.MSComm1.DTREnabl
End If
'RTSEnable
retSetting = GetSetting(App.Title, "Communications", "RTS Enable")
If retSetting <> "True" Or retSetting <> "False" Then
startform.MSComm1.RTSEnabl
SaveSetting App.Title, "Communications", "RTS Enable", startform.MSComm1.RTSEnabl
Else
startform.MSComm1.RTSEnabl
End If
'settings
retSetting = GetSetting(App.Title, "Communications", "Settings")
If retSetting = "" Then
startform.MSComm1.Settings
SaveSetting App.Title, "Communications", "Settings", startform.MSComm1.Settings
Else
startform.MSComm1.Settings
End If
'tmrBufferPoll
retSetting = GetSetting(App.Title, "Communications", "Buffer Poll (ms)")
If retSetting = "" Or Not IsNumeric(retSetting) Then
startform.tmrBufferPoll.In
SaveSetting App.Title, "Communications", "Buffer Poll (ms)", startform.tmrBufferPoll.In
Else
startform.tmrBufferPoll.In
End If
'************ Network
'Retry minutes
retSetting = GetSetting(App.Title, "Network", "Retry (min)")
If retSetting = "" Or Not IsNumeric(retSetting) Then
networkTryMinutes = 15
SaveSetting App.Title, "Network", "Retry (min)", networkTryMinutes
Else
networkTryMinutes = CInt(retSetting)
End If
'************************
doApplicationSettings = True
Exit Function
doApplicationSettingsError
Call ErrorHandler("AppSettings module", "doApplicationSettings", Err.Source, Err.Number, Err.Description)
doApplicationSettings = False
End Function
'default database locations
Public Const defaultSetupDB$ = "C:\Program Files\HLD2 Data Capture\HLD2SETUP.MDB"
Public Const defaultLocalQueueDB$ = "C:\Program Files\HLD2 Data Capture\local2Queue.mdb"
Public Const defaultNetworkQueueDB$ = "C:\Program Files\HLD2 Data Capture\network2Queue.mdb"
Public Const defaultLocalArchiveDB$ = "C:\Program Files\HLD2 Data Capture\local2Archive.mdb"
Public Const defaultErrorFile$ = "C:\Program Files\HLD2 Data Capture\HLD2Errors.txt"
Public Const defaultPasswordDB$ = "\\Suspous0020\departments
Public Const defaultNetworkDBPath$ = "\\Suspous0020\departments
Public Const defaultNetworkDBName$ = "hld2net"
ASKER
Settings on Data Control Property:
Connect = Access
DatabaseName = C:\Program Files\HLD2 Data Capture\local2Queue.mdb
DefaultType = 2 - UseJet
RecordsetType = 1 - Dynaset
RecordSource = localQueue '(which is table name in mdb file)
Other things on the Data Control property, it seems default.
Connect = Access
DatabaseName = C:\Program Files\HLD2 Data Capture\local2Queue.mdb
DefaultType = 2 - UseJet
RecordsetType = 1 - Dynaset
RecordSource = localQueue '(which is table name in mdb file)
Other things on the Data Control property, it seems default.
I did not see anything that looked wrong and you did everything fine. Is this happening only on your development machine?
ASKER
Yes, it is. Other developer who creates this program, it works on his pc.
Like I said to you yesterday, this source code was working on my pc before I install Microsoft visual studio 2005 source safe too.
Like I said to you yesterday, this source code was working on my pc before I install Microsoft visual studio 2005 source safe too.
ASKER
Data Control is coming from Microsoft Databound List Control 6.0, it located in c:\windows\system32\DBList
Thanks,
Annie
ASKER
Never mind what I said.
Data Control is default from VB6. Sorry for the confusing.
Data Control is default from VB6. Sorry for the confusing.
My is 6.1.97.82 and date is Tuesday, March 09, 2004. Yours is old and thats got to be it. Install Service pack 6 and you should be ok.
ASKER
I installed Service Pack 6 and it still does not work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think I'm going to uninstall VB6 and resintall it. Would that cause problem on Microsoft VS 2005?
Thanks very much for your help.
Thanks very much for your help.
It should not but if it does a reinstall will fix it.
ASKER
After Uninstall and reinstall vb6, it worked now.
Thank you very much for your help.
Thank you very much for your help.
OUTSTANDING.
I am glad we got to the bottom of this. Whew....... Glad I could help. Boy you should see the smile on my face LOL.
I am glad we got to the bottom of this. Whew....... Glad I could help. Boy you should see the smile on my face LOL.
ASKER
I know how you feel, I feel exactly same way.
Thank you so so much. That's one of the reason I never like DAO and Access database connection.
Thank you so so much. That's one of the reason I never like DAO and Access database connection.
Was something uninstall or installed? Something could be messing around with your DLL. Check the Dll version to make sure it is the same one that you have.
Also, are you using DAO or ADO? >>If .datLocalQueue.Recordset.B