VBA coding question

C

calsteve

Hi,
Have an Access 2003 database. The procedure is supposed to populate a
checkbox called PhysReview when a aate is entered in the DenialDate field. It
doesn't. What did I forget to do?
Thanks,
Steve

Private Sub DenialDate_AfterUpdate()
On Error GoTo Err_DenialDate_AfterUpdate

Dim stDate As Date
Dim intWeeks As Long

'Save data already entered
Me.Refresh

'Set Physician Review flag
Me!PhysReview = True

stDate = Me!DenialDate
If stDate > Now Then
MsgBox "WARNING: The Denial Date you entered is in the future"
GoTo Exit_DenialDate_AfterUpdate
End If

intWeeks = DateDiff("w", Now, stDate)
If Abs(intWeeks) > 0 Then
MsgBox "WARNING: The Denial Date you entered is more than 1 week in
the past"
GoTo Exit_DenialDate_AfterUpdate
End If

Exit_DenialDate_AfterUpdate:
Exit Sub

Err_DenialDate_AfterUpdate:
MsgBox Err.Description
Resume Exit_DenialDate_AfterUpdate
 
J

Jeff Boyce

Have you set a breakpoint in this code and 'stepped through' it as it works?
This would give you a way to see which lines are firing and what values are
being used.

By the way, if you already have a way to tell that a PhysReview is needed
(i.e., because there's a DenialDate value), why are you storing the same
fact twice? That is, why even bother with the checkbox if you already know?

Regards

Jeff Boyce
Microsoft Access MVP
 
C

calsteve

thanks, haven't tried stepping through. what is a break point?
Need the box to run specific reports for all instances where they are
reviewed. There are 3 possible dates used with the PhysReview and the
reports need to specifically filter for the review.
 
M

Mr. B

calsteve,

A break point is way for you to tell the code to halt execution and allow
you to "step" through it one line at a time.

With the VBA code window displayed, you can set the break point by locating
the line where you want your code to pause and click in the bar at the left
edge of the code. A dot will appear in the left bar and the line of code
will be highlighted. When your run your code it will now pause at this point
and you can then use the options from the "Debug" tool bar to move throuth
the code one line at a time. There is an option for stepping over a function
or other contained code.

Just one other observation, do some research (Access help file, or search on
line for debugging VBA code) on using the "immediate window" to check values
being returned by your code. You can also just hold your cursor over
variables or references to controls to see the current values in these
objects.

In short, there are a lot of tools that will help you when you are trying to
find a problem with your code.

Good Luck!

-----
HTH
Mr. B
http://www.askdoctoraccess.com/
Doctor Access Downloads Page:
http://www.askdoctoraccess.com/DownloadPage.htm
 
C

calsteve

Thanks,
The procedure works, the error messages work appropriately, its just that it
doesn't populate the check box. Ran the debugger previously and it found no
problems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top