-
Project gets stuck when running on Apple computer
My project written in VB 6.0 under Windows 10 is working perfectly.
When I use the same project on An Apple computer with VB 6.0 under Windows 10, when I run the project it gets stuck without showing any errors.
I put breakpoints in the starting form and I found out that it gets stuck after running the code :
Set rec1 = db1.OpenRecordset("Table2", dbOpenTable)
Before this code, I have the following code in Private Sub Form_Load()
Dim db1 As Database
Dim rec1 As Recordset
On Error Goto HandleErrors
Set db1 = OpenDatabase(App.Path & "\DataFiles\data2.mdb", False, False)
Set rec1 = db1.OpenRecordset("Table2", dbOpenTable)
The references selected are:
Visual Basic For Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
OLE Automation
Microsoft DAO 3.6 Object Library
Microsoft Data Formatting Object Library 6.0 (SP6)
Microsoft Excel 16.0 Object Library
Microsoft Data Binding Collection VB 6.0 (SP4)
Microsoft Data Report Designer 6.0 (SP4)
Microsoft Scripting Runtime
Microsoft Script Host Object Model
Microsoft ActiveX Data Objects 2.8 Library
Microsoft ActiveX Data Objects Recordset 2.8 Library
Microsoft WinHTTP Services, version 5.1
Microsoft XML, v6.0
Any suggestions?
-
Re: Project gets stuck when running on Apple computer
If I remember correctly .mdb is an access database. Does the apple box have access installed (if it shipped for apple) and can you open the database with that?
-
Re: Project gets stuck when running on Apple computer
It's just running on Windows 10, so the type of computer, in this case an Apple, should not matter.
Is OpenDataBase a part of DAO or is it a self written function?
What is the location of your application? I ask this because you have stored the DB file in a sub folder of the application.
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Arnoutdv
It's just running on Windows 10, so the type of computer, in this case an Apple, should not matter.
Is OpenDataBase a part of DAO or is it a self written function?
What is the location of your application? I ask this because you have stored the DB file in a sub folder of the application.
That's DAO, definitely (as you can see in his References).
But why he's referencing ADO too, escapes me.
Next: Is Excel/Office installed on that VM? (I'm guessing he runs Win10 in a VM on the Apple)
Lastly: App.Path & "\DataFiles....."
Depending how/where he installed his vb6-exe it might be running into a Write-Protect
IIRC, opening a mdb-file tries to create a loc-file?
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Arnoutdv
It's just running on Windows 10, so the type of computer, in this case an Apple, should not matter.
Is OpenDataBase a part of DAO or is it a self written function?
What is the location of your application? I ask this because you have stored the DB file in a sub folder of the application.
OpenDatabase is a part of DAO. The DB file is stored in a sub folder of the application this is true
-
Re: Project gets stuck when running on Apple computer
And where is the application located? In a restricted (sub) folder like "Program Files"?
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Zvoni
That's DAO, definitely (as you can see in his References).
But why he's referencing ADO too, escapes me.
Next: Is Excel/Office installed on that VM? (I'm guessing he runs Win10 in a VM on the Apple)
Lastly: App.Path & "\DataFiles....."
Depending how/where he installed his vb6-exe it might be running into a Write-Protect
IIRC, opening a mdb-file tries to create a loc-file?
Win10 is installed in a partiotion on the Apple and Ms Office 16.0 is installed.
What do you mean by "how/were vb6.0 is installed"?
-
Re: Project gets stuck when running on Apple computer
Not VB6.exe, your application. What is the location (path) of your application?
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Arnoutdv
Not VB6.exe, your application. What is the location (path) of your application?
It is in the folder "Application1", c:\Application1 and under this path are the data in a subfolder
-
Re: Project gets stuck when running on Apple computer
Then in theory there should not be a problem with opening and reading the DB file.
Quote:
I put breakpoints in the starting form and I found out that it gets stuck after running the code :
Set rec1 = db1.OpenRecordset("Table2", dbOpenTable)
So the last line does complete?
If yes, what are the next lines of code?
-
Re: Project gets stuck when running on Apple computer
App.Path may or may not contain already the last slash "/", so the code.
Code:
Set db1 = OpenDatabase(App.Path & "\DataFiles\data2.mdb", False, False)
is not correct.
If the exe it in the root of the disk, like C:\, it already contain the "".
I usually replace App.Path by a function:
Code:
Set db1 = OpenDatabase(App_Path & "\DataFiles\data2.mdb", False, False)
In a module:
Code:
Public Function App_Path() As String
App_Path = App.Path
If Right$(App_Path, 1) <> "\" Then App_Path = App_Path & "\"
End Function
Public if you put it on a module, but if you put this on the form's code, it can be private.
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Arnoutdv
Then in theory there should not be a problem with opening and reading the DB file.
So the last line does complete?
If yes, what are the next lines of code?
Remember: he has an active Error-Handler
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
dimbil
it gets stuck after
"it gets stuck" is not very precise...
Are you running it in the IDE?
What error do you have?
Remove the error handler to see what is happening.
-
Re: Project gets stuck when running on Apple computer
Is there an error or does the application freeze??
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Arnoutdv
Then in theory there should not be a problem with opening and reading the DB file.
So the last line does complete?
If yes, what are the next lines of code?
No, the last line of code doesn't complete. This is the line of code where it gets stuck when executing
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Arnoutdv
Is there an error or does the application freeze??
There is no error. The application freezes
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Eduardo-
"it gets stuck" is not very precise...
Are you running it in the IDE?
What error do you have?
Remove the error handler to see what is happening.
There is no error. I will remove the error handler and I will tell you what is happening.
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
dimbil
There is no error. I will remove the error handler and I will tell you what is happening.
Check if "db1" is a valid (Database)-Object (in Watch-Window?). Maybe OpenDatabase fails and returns "Nothing"
EDIT: Wait a sec. He has DAO and ADO referenced, but his "Dim rs1 As Recordset" is not qualified if it's a DAO or ADO-Recordset.
That said: It's really weird, because there should be some explicit errors
And do you really need all those References? I'd try remove one after the other (going Bottom-Up. Start with the last)
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Zvoni
Check if "db1" is a valid (Database)-Object (in Watch-Window?). Maybe OpenDatabase fails and returns "Nothing"
EDIT: Wait a sec. He has DAO and ADO referenced, but his "Dim rs1 As Recordset" is not qualified if it's a DAO or ADO-Recordset.
That said: It's really weird, because there should be some explicit errors
And do you really need all those References? I'd try remove one after the other (going Bottom-Up. Start with the last)
Yes, I need all those references.
Ona normal PC with VB6.0 under Windows 10 the code is working perfectly.
Maybe I should change "Dim rs1 As Recordset" to "Dim rs1 As ADO.Recordset" ?
-
Re: Project gets stuck when running on Apple computer
No, you are using DAO to open the database, so you should use DAO references everywhere!
And again it's a normal computer running Windows 10.
Is it running on a Virtual Machine with something like Parallels or is Boot Camp used?
https://machow2.com/best-way-run-windows-mac/
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Arnoutdv
No, you are using DAO to open the database, so you should use DAO references everywhere!
And again it's a normal computer running Windows 10.
Is it running on a Virtual Machine with something like Parallels or is Boot Camp used?
https://machow2.com/best-way-run-windows-mac/
But before this reference, in the same form, I use another one which runs normally with no problems.
This is as follows:
Dim db As Database
Dim rec As Recordset
Set db = OpenDatabase(App.Path & "\DataFiles\data1.mdb", False, False)
Set rec = db.OpenRecordset("Table1", dbOpenTable)
-
Re: Project gets stuck when running on Apple computer
Maybe the the table “Table2” is corrupt?
Did you check the actual database file?
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
dimbil
But before this reference, in the same form, I use another one which runs normally with no problems.
This is as follows:
Dim db As Database
Dim rec As Recordset
Set db = OpenDatabase(App.Path & "\DataFiles\data1.mdb", False, False)
Set rec = db.OpenRecordset("Table1", dbOpenTable)
I would fully qualify the type declaration if you have both libraries referenced, just to be sure.
Code:
Dim db As DAO.Database
Dim rec As DAO.Recordset
-
Re: Project gets stuck when running on Apple computer
I tried this but didn't correct the problem
-
Re: Project gets stuck when running on Apple computer
I am running it in the IDE.
I removed the error handler but it didn't help. The problem still exists
-
Re: Project gets stuck when running on Apple computer
Hmmm….. OP said he has Win10 on a separate partition of this (Apple) Harddrive.
i‘m not familiar with Apple (APFS?) but maybe it‘s the harddisk-controller messing stuff up when trying to read/write to NTFS
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Arnoutdv
Is it running on a Virtual Machine with something like Parallels or is Boot Camp used?
Bootcamp is not a virtual machine. It does not run under MacOS as it's just another boot partition.
Edit: Sorry did not see "or is" just saw "or".
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Zvoni
Hmmm….. OP said he has Win10 on a separate partition of this (Apple) Harddrive.
i‘m not familiar with Apple (APFS?) but maybe it‘s the harddisk-controller messing stuff up when trying to read/write to NTFS
It’s just a computer with a normal hdd/ssd. Nothing to do with the Apple file system
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Arnoutdv
It’s just a computer with a normal hdd/ssd. Nothing to do with the Apple file system
No, it's not.
Quote:
Originally Posted by
dimbil
Win10 is installed in a partiotion on the Apple and *snipp*
Is this even legal?
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Zvoni
No, it's not.
Yes it is, if you use Boot Camp.
The same as if you install Linux and Windows as dual boot on a 'normal' PC.
But you can also use Parallels and run Windows 10 side by side
Quote:
Originally Posted by
Zvoni
Is this even legal?
Yes of course, just buy a Windows 10/11 license and install it.
From the Apple website:
https://support.apple.com/guide/mac-...ac-mh11850/mac
-
Re: Project gets stuck when running on Apple computer
Then the last thing coming to mind would be, if his Office is a "Pro" and if he can open the mdb in Access directly
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
Arnoutdv
It's just running on Windows 10, so the type of computer, in this case an Apple, should not matter.
Is OpenDataBase a part of DAO or is it a self written function?
What is the location of your application? I ask this because you have stored the DB file in a sub folder of the application.
Sorry. Poor reading on my behalf
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
dimbil
I am running it in the IDE.
I removed the error handler but it didn't help. The problem still exists
Have you tried open the actual DB file directly from MS-Access on the Apple computer?
Or copy the DB file to another computer to check the integrity of the DB file
-
Re: Project gets stuck when running on Apple computer
Sorry if this has already been said. I read over most of the posts here but not all.
You say it freezes. Have you tried hitting break in the IDE when it freezes to see if it show you where it is having an issue?
Have you tried steeping through the code to see where it hangs?
Have you tried adding any debug or logging code to get an idea of what it happening at run time?
Clearly you are using DAO for the db operations. Is there a reason you have ADO referenced also? Typically you would use one or the other not both.
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
cidtek
Bootcamp is not a virtual machine. It does not run under MacOS as it's just another boot partition.
Edit: Sorry did not see "or is" just saw "or".
It runs under windows 10 installed in a partition of apple
-
Re: Project gets stuck when running on Apple computer
I am using both DAO and ADO db operations ince they were working perfectly on a PC with Windows 10. The problem is when running the project on an apple computer. I will change my code using only DAO to see if it will run
-
Re: Project gets stuck when running on Apple computer
I have done it and the DB file opens regularly on the apple computer
-
Re: Project gets stuck when running on Apple computer
I see you did not answer the questions about have you tried using break, logging or stepping through the code to see where it is actually hanging up.
This should be your first step. Much easier to fix a problem once you know where the problem occurs.
-
Re: Project gets stuck when running on Apple computer
Quote:
Originally Posted by
DataMiser
I see you did not answer the questions about have you tried using break, logging or stepping through the code to see where it is actually hanging up.
This should be your first step. Much easier to fix a problem once you know where the problem occurs.
I have used breakpoints and the code is hanging up when executing the command Set rec = db.OpenRecordset("Table1", dbOpenTable)
-
Re: Project gets stuck when running on Apple computer
Then I still think your DB file is corrupted.
Because you said earlier that following does work
Code:
Set rec = db.OpenRecordset("Table2", dbOpenTable)