Can't get Debug to Work

  • Thread starter Thread starter Guest
  • Start date Start date
I have tried. But breakpoint doesn't work either. I know the code is being
executed, but it doesn't stop at the BP. I feel like I am missing a setting
somewhere, but I don't think there is such a thing
 
Dave14117 said:
I have tried. But breakpoint doesn't work either. I know the code is
being executed, but it doesn't stop at the BP. I feel like I am
missing a setting somewhere, but I don't think there is such a thing

If you've played with database security settings, as for instance
the Use Access Special Keys, then often times the AllowBreakIntoCode
property follows. If so, try unchecking the Special Keys thingie, and
see if that helps, else try something like the following

Dim dbs As Database
Set dbs = CurrentDb

with dbs
.Properties("AllowSpecialKeys") = True
.Properties("AllowBreakIntoCode") = True
end with
 
Dave,
This is very interesting... Are you absolutely sure the code is running? Sorry, but I
know I've been fooled a few times when my breakpoint didn't trigger.
Recently, in a complicated DAO loop I used the Stop function to break the loop when a
certain value was encountered...
If GID = 1527 Then
Stop
 
Dave,
Sorry about the previous post. Sent prematurely by mistake...

This is very interesting... Are you absolutely sure the code is running? Sorry to ask
that again, but I
know I've been fooled a few times when a breakpoint didn't trigger. A trick I use is to
put a Beep in the code.

Recently, in a complicated and long DAO loop I used the Stop function to break the loop
when a
certain value was encountered...
If GID = 1527 Then
Stop
End If
Try using a Stop and see if that works.
 
I used MsgBox to verify code was being executed. (Beep would be better.)
Actually the code even works as far as I got; now that I'm trying to add a
few things, I need to debug. But no-go -- neither breakpoints or normal F8
work.

Here is code. Breakpoint at the OpenForm did not work. Form did open, "2"
did appear as message.


Private Sub Customer_Name_NotInList(NewData As String, _
Response As Integer)
' Prompt user to verify they wish to add new value.
If MsgBox("Value is not in list. Add it?", vbOKCancel, "Add New User?")
= vbOK _
Then
MsgBox "1"

DoCmd.OpenForm "frmCustomers", , , , acFormAdd

'DoCmd.GoToRecord acActiveDataObject, , acNewRec
'frmcustomers.["Last Name First Name"] = NewData
' Set Response argument to indicate that data
' is being added.
MsgBox "2"
Response = acDataErrContinue
Else
' If user chooses Cancel, suppress error message
' and undo changes.
Response = acDataErrContinue
'ctl.Undo
End If
 
Tom - I have not changed Use Access Special Keys -- it's unchecked. Also not
familiar with the Database type (?).
 
Dave14117 said:
Tom - I have not changed Use Access Special Keys -- it's unchecked.
Also not familiar with the Database type (?).

Ah - the other way around - if it's unchecked, then it might be the
problem, try checking it and see if it works. If not, try the code
snippet I pasted. You will probably need to close the db and reopen
it for it to take effect.
 
Ok. Just checking the Special Keys box didn't change anything for now. I am
not understanding the snippet. Is Database a type?
 
Dave14117 said:
Ok. Just checking the Special Keys box didn't change anything for
now. I am not understanding the snippet. Is Database a type?

Yes, it is a datatype. If it isn't recognized, then you probably
haven't set a reference to Microsoft DAO 3.# Object Library (in
Tools | References).
 
Got it.

So -- now the sub apparently doesn't get entered, which is another mystery.
When there's something amiss in the code, I get the default message for the
event. If I comment out the Database/properties code, the sub is entered.
 
Dave14117 said:
Got it.

So -- now the sub apparently doesn't get entered, which is another
mystery. When there's something amiss in the code, I get the default
message for the event. If I comment out the Database/properties
code, the sub is entered. --
Thanks,

Dave

The snippet is supposed to only be run once - place it in a standard
module, to alter the settings "to normal". Then when you wish to
"secure" the app again, run it again, then with False (or do a search
in these NGs, as there are lots of solutions/suggestions for setting
properties like this in code.

Private Sub ChangeSomeProps()

Dim dbs As DAO.Database
Set dbs = CurrentDb

With dbs
.Properties("AllowSpecialKeys") = True
.Properties("AllowBreakIntoCode") = True
End With
Set dbs = Nothing

End Sub
 
Roy - Settings do not alter problem.

I am a newbie and have a disc of sample solutions. I notice that not only
for my own forms code, but also for the solutions from the book's disc, that
debug does not work for anything in Project Explorer in the Microsoft Office
Access Class Objects folder, where my forms code resides, but does work for
the disc's code that's in the Modules folder.
 
Dave14117 said:
Roy - Settings do not alter problem.

I am a newbie and have a disc of sample solutions. I notice that not
only for my own forms code, but also for the solutions from the
book's disc, that debug does not work for anything in Project
Explorer in the Microsoft Office Access Class Objects folder, where
my forms code resides, but does work for the disc's code that's in
the Modules folder. --
Thanks very much,

Dave

I'm perhaps misunderstanding - debug is (or rather, should be) possible
both for form/reports class modules, as with routines in standard
modules. There is one difference, though, form/report code cannot be
initialized from VBE (as far as I know, that is), as you can with
routines residing in standard modules. I'm wondering if this was
possible in a97, but was removed in a2k, but am not sure.

To start debugging/running form/report code, you'll probably need to
trigger it from the form (a button, an event...), but then it should
stop at breakpoints, or at Stop statements, and you should be able to
Step into (F8), step over (Shift+F8)...

In the cases where it does not stop, then I've found that either I or
someone else, has changed some of the properties I've discussed, and
checking the Special Keys thingie, or running such snippet has resolved
the issue.
 
Back
Top