Runtime error on changing selection (1 Viewer)

AlexN

Registered User.
Local time
Today, 10:55
Joined
Nov 10, 2014
Messages
302
Hi everyone,

I have a Main form (MainForm) with two subforms (SFormA, SFormB).
These SForms are connected to the MainForm by a control (controlA) and connected to each other by a control (controlB) via an unbound control in the main form, in order to change data in SFormB according to selected record in SFormA.
SFormB has an on current event procedure determined to show different things depending on the value of a bound control that changes every time I select a different record in SFormA.
Everything works fine when Mainform and SForms first load. But, when I select a record on SFormA I get a runtime error and everything stops, application closes and reopens, creating a safety copy. It seems to me that the on current procedure on SFormB causes this problem, because if I delete it no error appears (SFormB not showing what I want though).
Funny thing is I have another database, same design, same structure, same procedures, (different objects and names of course) and it works perfectly alright.
I’m struggling for days with this, nothing doing. I even recreated the whole database still the same error. Anyone has some redemptive idea?
Thank you

Nick
 

Attachments

  • Runtime.JPG
    Runtime.JPG
    28.1 KB · Views: 59

JHB

Have been here a while
Local time
Today, 09:55
Joined
Jun 17, 2012
Messages
7,732
Show the code you've, or even better post a stripped down version of your database with some sample code, (zip it) + description how to reproduce the error!
 

AlexN

Registered User.
Local time
Today, 10:55
Joined
Nov 10, 2014
Messages
302
Show the code you've, or even better post a stripped down version of your database with some sample code, (zip it) + description how to reproduce the error!

A stripped version of the database is almost impossible, I'll try it though but is gonna take some time. Meanwhile there's the code behind the on currnet event, that seems to cause the problem.

Code:
Private Sub Form_Current()
If Me.TabletCategoryID = 1 Then
Me.DepositsPage.Visible = True
Me.SubFrmDepositTransactions.Enabled = True
Me.BuyPage.Visible = False
Me.SubFrmBuyTransactions.Enabled = False
Me.SellPage.Visible = False
Me.SubFrmSellTransactions.Enabled = False
Me.WithdrawalPage.Visible = False
Me.SubFrmWithdrawalTransactions.Enabled = False
Else
If Me.TabletCategoryID = 2 Then
Me.DepositsPage.Visible = False
Me.SubFrmDepositTransactions.Enabled = False
Me.BuyPage.Visible = True
Me.SubFrmBuyTransactions.Enabled = True
Me.SellPage.Visible = False
Me.SubFrmSellTransactions.Enabled = False
Me.WithdrawalPage.Visible = False
Me.SubFrmWithdrawalTransactions.Enabled = False
Else
If Me.TabletCategoryID = 3 Then
Me.DepositsPage.Visible = False
Me.SubFrmDepositTransactions.Enabled = False
Me.BuyPage.Visible = False
Me.SubFrmBuyTransactions.Enabled = False
Me.SellPage.Visible = True
Me.SubFrmSellTransactions.Enabled = True
Me.WithdrawalPage.Visible = False
Me.SubFrmWithdrawalTransactions.Enabled = False
Else
Me.DepositsPage.Visible = False
Me.SubFrmDepositTransactions.Enabled = False
Me.BuyPage.Visible = False
Me.SubFrmBuyTransactions.Enabled = False
Me.SellPage.Visible = False
Me.SubFrmSellTransactions.Enabled = False
Me.WithdrawalPage.Visible = True
Me.SubFrmWithdrawalTransactions.Enabled = True
End If
End If
End If
End Sub


Thank you for your time
 

spikepl

Eledittingent Beliped
Local time
Today, 09:55
Joined
Nov 3, 2010
Messages
6,142
You have supplied a mess of information, not saying which form is which, so hard to guess anything, so I won't even bother.

You are doing a lot of setting things not visible or disabling them and those operations are not always without consequences, because they may disallow operations that we cannot see from the supplied code.

One by one, comment out the lines that set things invisible or enabled=false, and see where that leads you. Or even better, comment them all out, and comment them in one by one.

We have no remote vision, so have to work with what you supply, and that is not much. Paste the stripped version.
 

AlexN

Registered User.
Local time
Today, 10:55
Joined
Nov 10, 2014
Messages
302
You have supplied a mess of information, not saying which form is which, so hard to guess anything, so I won't even bother.

You are doing a lot of setting things not visible or disabling them and those operations are not always without consequences, because they may disallow operations that we cannot see from the supplied code.

One by one, comment out the lines that set things invisible or enabled=false, and see where that leads you. Or even better, comment them all out, and comment them in one by one.

We have no remote vision, so have to work with what you supply, and that is not much. Paste the stripped version.

Ok, I'll come with a stripped version, but it's gonna take some time.

However, if I may become more clear :

A main form has two subforms. By selecting a record on SformA, I want to display specific data on SformB. So I have an unbound control on Mainform that takes values from SformA and connects to SformB.
SFormB now, has a tabcrtl with 4 pages and subforms, which I want to be enabled and visible depending on the value of a certain control on SformB.
That's why I put the code attached below, behind the on current event of SformB.
Problem is, every time I select a record from SformA I get the below mentioned message and application closes, although I have the time to notice that data on sformB changes the right way. Please notice that this doesn't happen all the time but it happens annoyingly often.
And If I may state again, I'm already using the same logic and technique in another project of mine with almost the same structure, and running it for some months without a problem.

Posting a stripped version of the database will take some time, because I'll have to change all label captions in English (they are in Greek) so you might understand something, and it comes with 40 tables, and queries and forms of the same count.

So, please forgive my causing you such a frustration, after all I'm trying to explain my problem in a foreign language.


Thanks
 

spikepl

Eledittingent Beliped
Local time
Today, 09:55
Joined
Nov 3, 2010
Messages
6,142
Do everybody a favour find out which line causes the problem. Try stepping though using the debugger or insert a bunch of msgbox into the code.

Thee above is basic stuff that you can do yourself.
 

vbaInet

AWF VIP
Local time
Today, 08:55
Joined
Jan 22, 2010
Messages
26,374
The runtime error you're getting is as a result of a lack of error handling and this happens in a compiled version of Access (i.e. mde or accde) and (I believe) in a runtime version too (i.e. accde).

Like spikepl mentioned, run the code (as an accdb) and when it errors tell us which line it errors and what the exact error message is.
 

AlexN

Registered User.
Local time
Today, 10:55
Joined
Nov 10, 2014
Messages
302
The runtime error you're getting is as a result of a lack of error handling and this happens in a compiled version of Access (i.e. mde or accde) and (I believe) in a runtime version too (i.e. accde).

Like spikepl mentioned, run the code (as an accdb) and when it errors tell us which line it errors and what the exact error message is.




I'm not sure I really understood this, the file is an accdb file, not an mde neither an accde. However I ran the code line by line and had this result:


Code:
Private Sub Form_Current()
If Me.TabletCategoryID = 1 Then
Me.DepositsPage.Visible = True
Me.SubFrmDepositTransactions.Enabled = True
Me.BuyPage.Visible = False
Me.SubFrmBuyTransactions.Enabled = False
Me.SellPage.Visible = False
Me.SubFrmSellTransactions.Enabled = False
Me.WithdrawalPage.Visible = False
Me.SubFrmWithdrawalTransactions.Enabled = False
Else
If Me.TabletCategoryID = 2 Then
Me.DepositsPage.Visible = False
Me.SubFrmDepositTransactions.Enabled = False

It runs smoothly till this line. When I run the following it brings up the error message. Not a vba message, but the message I attached earlier. I even uninstalled and clearly reinstalled Office 2010.


Code:
Me.BuyPage.Visible = True
Me.SubFrmBuyTransactions.Enabled = True
Me.SellPage.Visible = False
Me.SubFrmSellTransactions.Enabled = False
Me.WithdrawalPage.Visible = False
Me.SubFrmWithdrawalTransactions.Enabled = False
Else
If Me.TabletCategoryID = 3 Then
Me.DepositsPage.Visible = False
Me.SubFrmDepositTransactions.Enabled = False
Me.BuyPage.Visible = False
Me.SubFrmBuyTransactions.Enabled = False
Me.SellPage.Visible = True
Me.SubFrmSellTransactions.Enabled = True
Me.WithdrawalPage.Visible = False
Me.SubFrmWithdrawalTransactions.Enabled = False
Else
Me.DepositsPage.Visible = False
Me.SubFrmDepositTransactions.Enabled = False
Me.BuyPage.Visible = False
Me.SubFrmBuyTransactions.Enabled = False
Me.SellPage.Visible = False
Me.SubFrmSellTransactions.Enabled = False
Me.WithdrawalPage.Visible = True
Me.SubFrmWithdrawalTransactions.Enabled = True
End If
End If
End If
End Sub



I don't know what to do next.:(
 

vbaInet

AWF VIP
Local time
Today, 08:55
Joined
Jan 22, 2010
Messages
26,374
On closer inspection it appears to be a pretty unique error message. It seems to be an application failure as opposed to an error thrown during runtime. I didn't notice the C++ part to it.

My belief is that your form or perhaps your db is corrupt. I would advise that you create a new form from scratch (without copying any controls across), but you can copy the code over. Or use SaveAsText() and LoadFromText() functions to save your form as text and load it from the saved text. That should remove any corruption that may have crept in.

Also check the References to ensure that they're all intact.
 

AlexN

Registered User.
Local time
Today, 10:55
Joined
Nov 10, 2014
Messages
302
On closer inspection it appears to be a pretty unique error message. It seems to be an application failure as opposed to an error thrown during runtime. I didn't notice the C++ part to it.

My belief is that your form or perhaps your db is corrupt. I would advise that you create a new form from scratch (without copying any controls across), but you can copy the code over. Or use SaveAsText() and LoadFromText() functions to save your form as text and load it from the saved text. That should remove any corruption that may have crept in.

Also check the References to ensure that they're all intact.



Thank you, I'll try this too...
 

AlexN

Registered User.
Local time
Today, 10:55
Joined
Nov 10, 2014
Messages
302
On closer inspection it appears to be a pretty unique error message. It seems to be an application failure as opposed to an error thrown during runtime. I didn't notice the C++ part to it.

My belief is that your form or perhaps your db is corrupt. I would advise that you create a new form from scratch (without copying any controls across), but you can copy the code over. Or use SaveAsText() and LoadFromText() functions to save your form as text and load it from the saved text. That should remove any corruption that may have crept in.

Also check the References to ensure that they're all intact.

I have completely deleted the form and subforms, redesigned them, wrote the code from the very beginning (nothing copy-pasted) and still have the same problem, only this time it asks if I want to send a report to Microsoft.

References checked:

  • Visual Basic for Applications
  • Micorsoft Access 14.0 Object Library
  • OLE automation
  • Micorsoft Office 14.0 Access database engine Object Library


For haven's sake!!! I got it working smoothly for months in another project!!! I think it's time I quit!!!
 
Last edited:

vbaInet

AWF VIP
Local time
Today, 08:55
Joined
Jan 22, 2010
Messages
26,374
Quite basic references so it shouldn't cause any problems. So now what happens, it displays the same error message as before and then crashes?
 

AlexN

Registered User.
Local time
Today, 10:55
Joined
Nov 10, 2014
Messages
302
Quite basic references so it shouldn't cause any problems. So now what happens, it displays the same error message as before and then crashes?

Yes, same thing again. I can't think of anything I haven't already tried.
 

vbaInet

AWF VIP
Local time
Today, 08:55
Joined
Jan 22, 2010
Messages
26,374
You might need to re-install Access. What version of Access (i.e. the db version and also the version that's being used to open the db) are you running? Also tell us your version of Windows.

Somewhere down the line, we may still need a cut-down version of your db (as already requested by others). Just so that we can test it on our end.
 

AlexN

Registered User.
Local time
Today, 10:55
Joined
Nov 10, 2014
Messages
302
You might need to re-install Access. What version of Access (i.e. the db version and also the version that's being used to open the db) are you running? Also tell us your version of Windows.

Somewhere down the line, we may still need a cut-down version of your db (as already requested by others). Just so that we can test it on our end.

I've already fully uninstalled and clear reinstalled Office 2010 fully updated. I'm running Windows 7 ultimate 32bit.

But all this doesn't make sense. I told you I have the exact same technique, the exact same code, in another Access project with similar structure, running fine for months.
 

vbaInet

AWF VIP
Local time
Today, 08:55
Joined
Jan 22, 2010
Messages
26,374
But all this doesn't make sense. I told you I have the exact same technique, the exact same code, in another Access project with similar structure, running fine for months.
Similar structure or the same structure?

Here's another suggestion:

1. Create a new blank db
2. Use the Import/Export wizard to import all the objects from the problem db into the new db - don't copy and paste.
3. Debug > Compile... fix any reference issues
4. Save
5. Compact & Repair and re-test.
 

AlexN

Registered User.
Local time
Today, 10:55
Joined
Nov 10, 2014
Messages
302
And how many users do you have? Is your db split?



No it isn't. I am and will remain the only user. I'm developing it for educational reasons, I'm not planning to distribute it.
 

vbaInet

AWF VIP
Local time
Today, 08:55
Joined
Jan 22, 2010
Messages
26,374
Ok, it's still worth splitting it but it's not a big issue for single use.

Try the above without missing a step and let me know how it pans out.
 

AlexN

Registered User.
Local time
Today, 10:55
Joined
Nov 10, 2014
Messages
302
Similar structure or the same structure?

Here's another suggestion:

1. Create a new blank db
2. Use the Import/Export wizard to import all the objects from the problem db into the new db - don't copy and paste.
3. Debug > Compile... fix any reference issues
4. Save
5. Compact & Repair and re-test.

Done that already.Still the same....


Tomorrow I'll start it all over again....from scratch.......:(
 

Users who are viewing this thread

Top Bottom