Solved Error 2447 (1 Viewer)

mike60smart

Registered User.
Local time
Today, 23:06
Joined
Aug 6, 2017
Messages
1,909
Hi Everyone

I am trying to use the following Code in the OnCurrent Event of the Form

Code:
40      If Me.txtStatus = "Billed" Then
50      Me.cboRateType.Enabled = False

60      Else

70      Me.cboRateType.Enabled = True

80      End If
When the Form opens I get the following error:-

Any help appreciated.
 

Attachments

  • Error.PNG
    Error.PNG
    6.5 KB · Views: 57

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:06
Joined
May 7, 2009
Messages
19,246
try using Nz(Me.txtStatus, "") ="Billed" Then

Me.cboRateType.Enabled = (Nz(Me!txtStatus, "") = "Billed")
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:06
Joined
Sep 21, 2011
Messages
14,369
Are you sure you have the correct line 40? :(
 

mike60smart

Registered User.
Local time
Today, 23:06
Joined
Aug 6, 2017
Messages
1,909
try using Nz(Me.txtStatus, "") ="Billed" Then

Me.cboRateType.Enabled = (Nz(Me!txtStatus, "") = "Billed")
Hi arnelgp

Changed to your suggested Code and now get the following error:-
 

Attachments

  • Error.PNG
    Error.PNG
    7.6 KB · Views: 60

Gasman

Enthusiastic Amateur
Local time
Today, 23:06
Joined
Sep 21, 2011
Messages
14,369
Perhaps show all of form_current event?
I would have thought you would have got Invalid use of Null if NZ() was able to fix it?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:06
Joined
May 7, 2009
Messages
19,246
try to Compile your code and see if it will reveal any errors.
 

mike60smart

Registered User.
Local time
Today, 23:06
Joined
Aug 6, 2017
Messages
1,909
Perhaps show all of form_current event?
I would have thought you would have got Invalid use of Null if NZ() was able to fix it?
Hi Gasman

I only uploaded what I thought were the lines needed but here with the Full Code for the On Current:-

Code:
Private Sub Form_Current()

10        On Error GoTo Form_Current_Error
20    Me.cboCustomer.SetFocus
30    Me.Accy_Amount.Requery

40    If Nz(Me.txtStatus, "") = "Billed" Then
50    Me.cboRateType.Enabled = False
60    Me.cboCustomer.Enabled = False
70    Me.[Pd Miles].Enabled = False
80    Me.RateQty.Enabled = False
90    Me.Rate.Enabled = False
100   Me.BaseRate.Enabled = False
110   Me.StopChg.Enabled = False
120   Me.Weight.Enabled = False
130   Me.[Accy Amount].Enabled = False
140   Me.Gross.Enabled = False
150   Me.NumStops.Enabled = False
160   Me.TotStChg.Enabled = False

170   Else

180   Me.cboRateType.Enabled = True
190   Me.cboCustomer.Enabled = True
200   Me.[Pd Miles].Enabled = True
210   Me.RateQty.Enabled = True
220   Me.Rate.Enabled = True
230   Me.BaseRate.Enabled = True
240   Me.StopChg.Enabled = True
250   Me.Weight.Enabled = True
260   Me.[Accy Amount].Enabled = True
270   Me.Gross.Enabled = True
280   Me.NumStops.Enabled = True
290   Me.TotStChg.Enabled = True

300   End If




         
310       On Error GoTo 0
320       Exit Sub

Form_Current_Error:

330       MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Current, line " & Erl & "."

End Sub
try to Compile your code and see if it will reveal any errors.
Hi arnelgp

Did that and no errors
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:06
Joined
May 21, 2018
Messages
8,555
Using @arnelgp trick where you are toggling (true, false). This can reduce some code and thus chances of bugs

Replace the If then with
Code:
10        On Error GoTo Form_Current_Error
20     Me.cboCustomer.SetFocus
30     Me.Accy_Amount.Requery

50    dim NotBilled as boolean
      NotBilled = (Nz(Me.txtStatus, "") <> "Billed")

      Me.cboRateType.Enabled = NotBilled
60    Me.cboCustomer.Enabled = NotBilled
70    Me.[Pd Miles].Enabled = NotBilled
80    Me.RateQty.Enabled = NotBilled
90    Me.Rate.Enabled = NotBilled
100   Me.BaseRate.Enabled = NotBilled
110   Me.StopChg.Enabled = NotBilled
120   Me.Weight.Enabled = NotBilled
130   Me.[Accy Amount].Enabled = NotBilled
140   Me.Gross.Enabled = NotBilled
150   Me.NumStops.Enabled = NotBilled
160   Me.TotStChg.Enabled = NotBilled
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:06
Joined
Sep 21, 2011
Messages
14,369
I see you are not of a believer in indentation? :(
I wanted to see the whole code, as sometimes Access shows a misleading error, caused by previous code?
I cannot see the cause, but I would certainly use arnel's logic as one liners.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:06
Joined
Feb 19, 2013
Messages
16,637
Have you tried stepping through the code
 

mike60smart

Registered User.
Local time
Today, 23:06
Joined
Aug 6, 2017
Messages
1,909
Using @arnelgp trick where you are toggling (true, false). This can reduce some code and thus chances of bugs

Replace the If then with
Code:
10        On Error GoTo Form_Current_Error
20     Me.cboCustomer.SetFocus
30     Me.Accy_Amount.Requery

50    dim NotBilled as boolean
      NotBilled = (Nz(Me.txtStatus, "") <> "Billed")

      Me.cboRateType.Enabled = NotBilled
60    Me.cboCustomer.Enabled = NotBilled
70    Me.[Pd Miles].Enabled = NotBilled
80    Me.RateQty.Enabled = NotBilled
90    Me.Rate.Enabled = NotBilled
100   Me.BaseRate.Enabled = NotBilled
110   Me.StopChg.Enabled = NotBilled
120   Me.Weight.Enabled = NotBilled
130   Me.[Accy Amount].Enabled = NotBilled
140   Me.Gross.Enabled = NotBilled
150   Me.NumStops.Enabled = NotBilled
160   Me.TotStChg.Enabled = NotBilled
Hi MajP
Using @arnelgp trick where you are toggling (true, false). This can reduce some code and thus chances of bugs

Replace the If then with
Code:
10        On Error GoTo Form_Current_Error
20     Me.cboCustomer.SetFocus
30     Me.Accy_Amount.Requery

50    dim NotBilled as boolean
      NotBilled = (Nz(Me.txtStatus, "") <> "Billed")

      Me.cboRateType.Enabled = NotBilled
60    Me.cboCustomer.Enabled = NotBilled
70    Me.[Pd Miles].Enabled = NotBilled
80    Me.RateQty.Enabled = NotBilled
90    Me.Rate.Enabled = NotBilled
100   Me.BaseRate.Enabled = NotBilled
110   Me.StopChg.Enabled = NotBilled
120   Me.Weight.Enabled = NotBilled
130   Me.[Accy Amount].Enabled = NotBilled
140   Me.Gross.Enabled = NotBilled
150   Me.NumStops.Enabled = NotBilled
160   Me.TotStChg.Enabled = NotBilled
Hi MajP
I have tried both yours and arnelgp's solutions with no luck.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:06
Joined
May 21, 2018
Messages
8,555
If that error message is correct (Double check because sometimes I copy and past the error handler and forget to change the module name as an agrument for the error)

The line you have or any example should not cause the error so I would comment out the error handler in the on current event and see where the code breaks.
Do you have a subform with the same error handler? It could be in the sub.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:06
Joined
May 21, 2018
Messages
8,555
If it is truly breaking in that module at line 40 (verified by removing error handler) then sometimes there gets confusion in the compiler. Make sure to do a debug compile. Then paste the code into a text file. Delete the entire module. Then I would re type the code up to line 40. If that works paste the rest back in.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:06
Joined
Feb 28, 2001
Messages
27,243
When I see this kind of problem (particularly if the error changes from a short error code - 2447 - to a long code), I think of corruption.

First, before you do anything else of this that I'm about to suggest, make a copy of your database file as a safety backup. Use the Windows File Explorer to do it. Straight up copy/paste. Don't copy it using any Access features at all.

Second, use a DECOMPILE on this errant file.


Third, perform a Compact & Repair.

Fourth, open the file as though you were going to do some design work. Use the VBA window to explicitly compile the code.

Now test it and see what you get.

If this still fails, then there is one other thing to consider. That long error code intrigued me. So I used the old "Programmer's Calculator" in Windows and determined that -2147352567 is 0x80020009 - which has NOTHING TO DO with dots and parentheses and bangs, despite what the error message actually says. That error suggests some kind of internal problem. Check your VBA Window >> Tools >> References to see if any of your references come up "Missing" or "Broken" or something else.

In the worst-case scenario, you might have to create an empty database and then use the "External Data" options to IMPORT everything from your backup copy. Then go in and verify proper references.
 

mike60smart

Registered User.
Local time
Today, 23:06
Joined
Aug 6, 2017
Messages
1,909
Hi Everyone

June7 suggested the following when I asked this question on Utter Access Forum this thread

Could just set the Locked property of the subform container control. I always name control different from the object it holds, like ctrLoad. So code in main form Current event:

Me.ctrLoad.Locked = Me.textboxname = "Billed"

So I tried the following in the On Current Event

Code:
Private Sub Form_Current()

10        On Error GoTo Form_Current_Error
          
20     Me.Accy_Amount.Requery

30     [Forms]![Dispatch]![frmLoadsBillingSubform].[Form].Locked = Me.txtStatus = "Billed"
        
40        On Error GoTo 0
50        Exit Sub

Form_Current_Error:

60        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Current, line " & Erl & "."

End Sub

This now generates the following 2 errors.

However when the Form Opens the Controls are Locked on the Subform/

Any thoughts?
 

Attachments

  • Error1.PNG
    Error1.PNG
    7.5 KB · Views: 47
  • Error2.PNG
    Error2.PNG
    5.5 KB · Views: 49

mike60smart

Registered User.
Local time
Today, 23:06
Joined
Aug 6, 2017
Messages
1,909
When I see this kind of problem (particularly if the error changes from a short error code - 2447 - to a long code), I think of corruption.

First, before you do anything else of this that I'm about to suggest, make a copy of your database file as a safety backup. Use the Windows File Explorer to do it. Straight up copy/paste. Don't copy it using any Access features at all.

Second, use a DECOMPILE on this errant file.


Third, perform a Compact & Repair.

Fourth, open the file as though you were going to do some design work. Use the VBA window to explicitly compile the code.

Now test it and see what you get.

If this still fails, then there is one other thing to consider. That long error code intrigued me. So I used the old "Programmer's Calculator" in Windows and determined that -2147352567 is 0x80020009 - which has NOTHING TO DO with dots and parentheses and bangs, despite what the error message actually says. That error suggests some kind of internal problem. Check your VBA Window >> Tools >> References to see if any of your references come up "Missing" or "Broken" or something else.

In the worst-case scenario, you might have to create an empty database and then use the "External Data" options to IMPORT everything from your backup copy. Then go in and verify proper references.
Hi Docman

I have already done a Compile of Access
I have Imported to a New Access File
I have Compact & Repaired
 

mike60smart

Registered User.
Local time
Today, 23:06
Joined
Aug 6, 2017
Messages
1,909
If that error message is correct (Double check because sometimes I copy and past the error handler and forget to change the module name as an agrument for the error)

The line you have or any example should not cause the error so I would comment out the error handler in the on current event and see where the code breaks.
Do you have a subform with the same error handler? It could be in the sub.
Hi MajP
I commented out the Error Handler and now get the error shown below.

It highlights this line:

Code:
30     [Forms]![Dispatch]![frmLoadsBillingSubform].[Form].Locked = Me.txtStatus = "Billed"
 

Attachments

  • Error.PNG
    Error.PNG
    6.8 KB · Views: 39

cheekybuddha

AWF VIP
Local time
Today, 23:06
Joined
Jul 21, 2014
Messages
2,289
Can you lock a form?

I thought you could only lock controls, but don't have Windows open to check
 

Users who are viewing this thread

Top Bottom