0

Something has happened to my database application where suddenly, the compilation errors don't make sense. I have tried repairing and even bringing the objects into another fresh database. Here's an example:

Private Sub cmbCumulateOBS_AfterUpdate()
   Select Case Me.cmbCumulateCOMMITS
    Case "OCT"
        Me.txtOCT_O = Me.txtOBS_Start
        Me.txtNOV_O = Me.txtOBS_Start * 2
        Me.txtDEC_O = Me.txtOBS_Start * 3
        Me.txtJAN_O = Me.txtOBS_Start * 4
        Me.txtFEB_O = Me.txtOBS_Start * 5
        Me.txtMAR_O = Me.txtOBS_Start * 6
        Me.txtAPR_O = Me.txtOBS_Start * 7
        Me.txtMAY_O = Me.txtOBS_Start * 8
        Me.txtJUN_O = Me.txtOBS_Start * 9
        Me.txtJUL_O = Me.txtOBS_Start * 10
        Me.txtAUG_O = Me.txtOBS_Start * 11
        Me.txtSEP_O = Me.txtOBS_Start * 12
    Case "NOV"

....

The error I receive is that txtOBS_Start does not exist - but it only does not exist for the txtSEP_O instance. How could that be?

What can I do to get my code working again?

plateriot
  • 361
  • 5
  • 23
  • Get into the habit of not relying on the default properties in MS Access. Use Me.txtOCT_O.Text = Me.txtOBS_Start.Text – HardCode Dec 01 '15 at 21:04
  • @HardCode: if anything, that would be `.Value`, not `.Text` (the latter is only valid when the control has the focus). But the whole thing is a matter of opinion - I find `Me.myControl` better readable than `Me.myControl.Value`, and both work the same. – Andre Dec 02 '15 at 00:30

3 Answers3

1

A Decompile may help. See this answer by David-W-Fenton:

https://stackoverflow.com/a/3268188/3820271

and follow the steps to the letter.

Community
  • 1
  • 1
Andre
  • 26,751
  • 7
  • 36
  • 80
0

My apologies if this is poor board etiquette...this ought to be a comment rather than an answer, but I appear to have insufficient board privileges for the former but not the latter...

If you comment out the apparently-offending line

'Me.txtSEP_O = Me.txtOBS_Start * 12

Does anything unexpected happen? (i.e., you get the same error, only its now on the "AUG" line rather than the "SEP" line)

Or does all compile and run as expected without that single line?

John Q. Noob
  • 181
  • 1
  • 2
  • 18
  • Again, my apologies to all if this is an inappropriate use of the board's "Answer" function. I'm just trying my best to be helpful. :) – John Q. Noob Dec 01 '15 at 19:15
  • I tried commenting out each case one by one and I found that this error crawls to the last word. Always. I tried renaming the text box and still no luck. Not sure if rewriting the sub routine will work. – plateriot Dec 01 '15 at 19:18
  • Just thinking out loud here more than anything, but if you temporarily commented out ALL of your code in that module, and just replaced it with a single line "msgbox me.txtOBS_START" does the msgbox at least display the correct value that you were expecting to see? – John Q. Noob Dec 01 '15 at 19:26
  • I am definitely not having any luck recreating this issue. I'd be happy to delete this answer and comments if you would like. :) – John Q. Noob Dec 01 '15 at 19:42
  • I did try the msgbox with txtOBS_START - no errors. But as soon as I make the code what it needs to be, I get the crawling error again. I even tried renaming the text box. – plateriot Dec 01 '15 at 20:10
0

Thank you for your help. A user has pointed out that the field txtOBS_start is pointing to (SEPT_O) is intentionally missing. So the error is correct.

000
  • 26,951
  • 10
  • 71
  • 101
plateriot
  • 361
  • 5
  • 23
  • Huh? That was a little unclear. :) Anyway, if the problem is solved, please accept an answer to mark the question solved. – Andre Dec 02 '15 at 11:14
  • Sorry. Let me clarify. I built 12 Fiscal Year text boxes for COMMIT not remembering that the OBLIGATION (O) side (supposedly also 12 months) would share September so when I built the logic I was really looking for a text box txtSEP_O that didn't exist. At least I learned how to Decompile. So I didn't loose anything. – plateriot Dec 02 '15 at 15:44