access 2003 crashing

R

richaluft

Having a problem with a form CmdBtn event, and wondering if anyone has
run into this problem .
CmdBtn 'onclick' event is used to do calculations, and then has
"DoCmd.Close" at end of code.
When this close event fires, the app fails, & I get errmsg of "access
not responding".
If it matters, my 'close' command is preceded by the end of a bypass
section (If----GoTo) which I recently added to the CmdBtn. I've not
checked to see if this crash occurs when the coding is NOT bypassed .
Any suggestions?
Happy new year.
 
R

richaluft

Having a problem with a form CmdBtn event, and wondering if anyone has
run into this problem .
CmdBtn 'onclick' event is used to do calculations, and then has
"DoCmd.Close" at end of code.
When this close event fires, the app fails, & I get errmsg of "access
not responding".
If it matters, my 'close' command is preceded by the end of a bypass
section (If----GoTo) which I recently added to the CmdBtn. I've not
checked to see if this crash occurs when the coding is NOT bypassed .
Any suggestions?
Happy new year.

I should add to the above that, if I take the close command out of the
code from this button and place it into a second CmdBtn, then I am
able to close the form without any problem. This, however, is not
what I desire in my coding.
 
J

Jeanette Cunningham

The first thought I have on this is that Access gets to the close command
before it has finished the calculation and this causes the crash.
One thing to try is to put these 2 lines directly before the DoCmd.Close
DoEvents
DoEvents

If that doesn't help, posting all the code for the click event of the close
button would help us to help you.

Jeanette Cunningham
 
R

richaluft

The first thought I have on this is that Access gets to the close command
before it has finished the calculation and this causes the crash.
One thing to try is to put these 2 lines directly before the DoCmd.Close
DoEvents
DoEvents

If that doesn't help, posting all the code for the click event of the close
button would help us to help you.

Jeanette Cunningham

Jeanette,
Since the crash occurs even when I go thru the code line-by-line, I
don't think that your supposition is the answer. The code (somewhat
simplified for brevity) follows:private Sub Button25_Click()
On Error GoTo Err_Button25_Click
DoCmd.SetWarnings False

Dim MySQL As String, MySQL1 As String, MySQL2 As String, Dt As String,
i As Integer
Dim DB As DAO.Database, rst As DAO.Recordset, rst1 As DAO.Recordset,
rst2 As DAO.Recordset, rst3 As DAO.Recordset, MySQL3 As String
Dim rst4 As DAO.Recordset, Mysql4 As String, Mysql5 As String, MySQL6
As String, MySQL7 As String, cp As Currency, D As Currency
Dim Precharges As Currency, Answer As Date, Answer1 As String, FeeReg
As Currency

DoCmd.Hourglass True


'SAVE RECORD
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20

'Then select all of "services" for this pt and for this insco# and
change
'values to new insco#, insaddress and insindex

'SET EARLIEST DATE FOR EFFECTIVE CHANGE
If Not IsNull(DMin("[Date_From]", "Services", "[patient ID#] = Forms!
[FInsuranceInfoEdit]![patient ID#] and Forms![FInsuranceInfoEdit]!
[SelectInsco]")) Then
Dt = DMin("[Date_From]", "Services", "[patient ID#] = Forms!
[FInsuranceInfoEdit]![patient ID#] and Forms![FInsuranceInfoEdit]!
[SelectInsco]") '??????
Else
MsgBox "No Services entered to correct"
DoCmd.Close acForm, "FInsuranceInfoEdit", acSaveYes
DoCmd.Hourglass False
Exit Sub
End If
DoCmd.Beep

Answer = InputBox$("First Svc Date for this patient is " & Dt & ":" &
Chr(13) & Chr(10) & "Enter effective date of this insurer correction"
& Chr(13) & Chr(10) & "Enter in format mm-dd-yyyy", , Dt)

Me![Effective Policy Date] = Format(Answer, "mm-dd-yyyy")






'UPDATE SERVICES SO THAT MONETARY DATA IS BLANK IN RST
MySQL2 = "UPDATE DISTINCTROW SERVICES SET SERVICES.lineinsurer =
[Forms].[FInsuranceInfoEdit].[SelectInsco], " & _
"SERVICES.[InsIndex#] = [Forms].[FInsuranceInfoEdit].[PolicyType], " &
_
"SERVICES.AddIndex = [Forms].[FInsuranceInfoEdit].[InsAddress], " & _
"SERVICES.linecoinsurer = [Forms].[FInsuranceInfoEdit].
[SelectCoinsco], " & _
"SERVICES.[CoInsIndex#] = [Forms].[FInsuranceInfoEdit].[CoPolicyType],
" & _
"SERVICES.CoAddIndex = [Forms].[FInsuranceInfoEdit].[CoInsAddress], "
& _
"SERVICES.AnnDeductCovered = [Forms].[FInsuranceInfoEdit].
[AnnDeductCovered], " & _
"SERVICES.ProceduralDeduct = [Forms].[FInsuranceInfoEdit].[ProcedureCo-
pay], " & _
"SERVICES.OfficeProcedureAmt = [Forms].[FInsuranceInfoEdit].
[OfcProcedureCo-PayFee], " & _
"SERVICES.HospProcedureAmt = [Forms].[FInsuranceInfoEdit].
[HospProcedCo-PayFee], " & _
"SERVICES.PayCatID = [Forms]![FInsuranceInfoEdit].[PayCatID], " & _
"SERVICES.Precharges = 0, SERVICES.Charges = 0, SERVICES.[Charges adj]
= 0, " & _
"SERVICES.ChargesApproved = 0, SERVICES.AnnualDeduct = 0,
SERVICES.deductapplied = 0, SERVICES.ProcedureDeductApplied = 0, " & _
"SERVICES.PreAnticPay = 0, SERVICES.PreAnticPay1 = 0,
SERVICES.PreAnticPay2 = 0, SERVICES.AnticPay = 0, " & _
"SERVICES.PatientOwes = 0, SERVICES.AnticCopay = 0, SERVICES.CoPay =
0, SERVICES.QUamt = 0 " & _
"WHERE (((SERVICES![Patient ID#])=[Forms].[FInsuranceInfoEdit].
[Patient ID#]) " & _
"AND ((SERVICES.Date_From) >=[Forms].[FInsuranceInfoEdit].[Effective
Policy Date])); "

DoCmd.RunSQL MySQL2


'RST for correction is SET HERE

Set DB = CurrentDb()
MySQL = "SELECT DISTINCTROW Services.* " & _
"FROM Services " & _
"WHERE (Services.lineinsurer= " & Me![SelectInsco] & ") " & _
"AND (Services.[Patient ID#]= " & Me![Patient ID#] & ") " & _
"AND (Services.Date_From >= " & Me![Effective Policy Date] & ") " & _
"ORDER BY Services.INVLINNUM;"
Set rst = DB.OpenRecordset(MySQL, dbOpenDynaset)
g = rst.RecordCount
If g > 0 Then
'SET PRECHARGES & CHARGES
Dim Insurance_Co As String, CCode As String, Days As Integer,
Modifiers As Integer, Billyear As Integer, fil As String
'determine linnumber of item
'find data for DLookup--insurance co name


rst.MoveFirst
Do Until rst.EOF

If rst!Mod1 = "26" Or rst!Mod1 = "TC" Then
c = rst!CPTCode & rst!Mod1

ElseIf rst!Mod2 = "26" Or rst!Mod2 = "TC" Then
c = rst!CPTCode & rst!Mod2

Else: c = rst!CPTCode
End If

y = DatePart("yyyy", rst!Date_From)


x = rst!paycatID


Select Case Val(x) ' Test input.

'note that several cases are omitted from code for brevity


Case 1, 4, 10, 11 'Medicare type 'ELIMINATE #3-Managed Care

'normal fee comes before lopay = -1
'if regular pay line is null, then fill in prices before rest of line
finishes
If IsNull(DLookup("[fee]", "FeeSchedCare", "[CPTCode] = '" & c
& "' And [year] ='" & y & "' And [lopay] = 0 ")) Then
'seek record where cpt code = C & lopay = no
DoCmd.OpenForm "FFeeSchedCare", , , ("[CptCode] = '" & c & "'
And [year] ='" & y & "' And [lopay] = 0 ")
End If
rst.Edit
If rst![Place of svc] <> 11 Then

If Not IsNull(DLookup("[fee]", "FeeSchedCare", "[CPTCode]
='" & c & "' And [year] = '" & y & "' And [lopay] = -1 ")) Then

rst!Precharges = DLookup("[fee]", "FeeSchedCare",
"[CPTCode] ='" & c & "' And [year] = '" & y & "' And [lopay] = -1 ")

ElseIf IsNull(DLookup("[fee]", "FeeSchedCare", "[CPTCode]
='" & c & "' And [year] = '" & y & "' And [lopay] = -1 ")) Then

rst!Precharges = DLookup("[fee]", "FeeSchedCare",
"[CPTCode] = '" & c & "' And [year] ='" & y & "' And [lopay] = 0 ")

End If

ElseIf rst![Place of svc] = 11 Then

rst!Precharges = DLookup("[fee]", "FeeSchedCare",
"[CPTCode] = '" & c & "' And [year] ='" & y & "' And [lopay] = 0 ")
rst.update
End If



Case 9
Msg = "Enter value for this miscellaneous charge"
MsgBox Msg ' Display message.
Exit Sub
End Select
rst.MoveNext
Loop



'SET CHARGE
rst.MoveFirst
Do Until rst.EOF
rst.Edit
If rst!Units = 1 Then
If rst!Mod1 = "50" Or rst!Mod2 = "50" Or rst!Mod3 = "50" Or
rst!Mod4 = "50" Then
rst!Charges = rst![Precharges] * 1.5
ElseIf rst!Mod1 = "53" Or rst!Mod2 = "53" Or rst!Mod3 = "53"
Or rst!Mod4 = "53" Then
rst!Charges = rst![Precharges] * 0.5
Else: rst!Charges = rst!Precharges
End If

ElseIf rst!Units <> 1 Then
rst![Charges] = rst![Precharges] * (rst!Units)
End If
rst.update
rst.MoveNext
Loop

The rest of these calculation steps are simply other examples of If--
Then and Do---loop sequences to perform calculations to set values of
rst fields. (Details have been omitted)


'Step2 'applydeduct 'sets [preanticpay]

'Step 3 apply co-pay

'Step4 'SetCoPayProcedural
'sets value of copayment for procedures for certain insurers

' setpercentpay 'step5


'Step6
'This sets [PatientOwes] and [AnticCoPay]


'Set QU value Step 7


'billdetailsupdate Step8

'finalize Step9


DoCmd.SetWarnings False
rst.MoveFirst
Do Until rst.EOF
MySQL7 = "UPDATE DISTINCTROW TBillDetails SET TBillDetails.InitBD1 =
Null, TBillDetails.LastBD1 = Null "
MySQL7 = MySQL7 & "WHERE TBillDetails.linenum = " & rst!LineNum & ";"

DoCmd.RunSQL MySQL7
rst.MoveNext
Loop
DoCmd.SetWarnings True
End If
rst.Close

DoCmd.SetWarnings True
DoCmd.Hourglass False
'THIS IS WHERE APPLICATION CRASHES
DoCmd.Close


Exit_Button25_Click:
Exit Sub

Err_Button25_Click:
MsgBox Error$
Resume Exit_Button25_Click
End Sub
 
S

Stefan Hoffmann

hi Rich,

Private Sub Button25_Click()
On Error GoTo Err_Button25_Click
DoCmd.SetWarnings False

Dim MySQL As String, MySQL1 As String, MySQL2 As String, Dt As String,
i As Integer
Dim DB As DAO.Database, rst As DAO.Recordset, rst1 As DAO.Recordset,
rst2 As DAO.Recordset, rst3 As DAO.Recordset, MySQL3 As String
Dim rst4 As DAO.Recordset, Mysql4 As String, Mysql5 As String, MySQL6
As String, MySQL7 As String, cp As Currency, D As Currency
Dim Precharges As Currency, Answer As Date, Answer1 As String, FeeReg
As Currency

DoCmd.Hourglass True


'SAVE RECORD
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20
Replace this with

If Me.Dirty Then
Me.Dirty = False
End If
'Then select all of "services" for this pt and for this insco# and
change
'values to new insco#, insaddress and insindex

'SET EARLIEST DATE FOR EFFECTIVE CHANGE
If Not IsNull(DMin("[Date_From]", "Services", "[patient ID#] = Forms!
[FInsuranceInfoEdit]![patient ID#] and Forms![FInsuranceInfoEdit]!
[SelectInsco]")) Then
Dt = DMin("[Date_From]", "Services", "[patient ID#] = Forms!
[FInsuranceInfoEdit]![patient ID#] and Forms![FInsuranceInfoEdit]!
[SelectInsco]") '??????
Else
MsgBox "No Services entered to correct"
DoCmd.Close acForm, "FInsuranceInfoEdit", acSaveYes
Use the default acSaveNo. This parameter controls whether to store
changes at the form object itself or not.

A few things to try:

Create a procedure to do the calculation and shorten the code for the
button like that:

Private Sub DoCalculation(ADate As Date)
'do the calculation here
End Sub

Private Sub Button25_Click()

On Local Error GoTo LocalError

Dim Dt As Variant

Dt = DMin("[Date_From]", _
"Services", _
"[patient ID#] = " & Me![patient ID#] & _
"AND [SelectInsco] = " & Me![SelectInsco]")

If IsNull(Dt) Then
MsgBox "No Services entered to correct"
DoCmd.Close acForm, Me.Name, acSaveNo
Else
DoCalculation Dt
End If

Exit Sub

LocalError:
'do error handling.

End Sub

Have you already run Compact and Repair?


mfG
--> stefan <--
 
R

richaluft

hi Rich,



Private Sub Button25_Click()
On Error GoTo Err_Button25_Click
DoCmd.SetWarnings False
Dim MySQL As String, MySQL1 As String, MySQL2 As String, Dt As String,
i As Integer
Dim DB As DAO.Database, rst As DAO.Recordset, rst1 As DAO.Recordset,
rst2 As DAO.Recordset, rst3 As DAO.Recordset, MySQL3 As String
Dim rst4 As DAO.Recordset, Mysql4 As String, Mysql5 As String, MySQL6
As String, MySQL7 As String, cp As Currency, D As Currency
Dim Precharges As Currency, Answer As Date, Answer1 As String, FeeReg
As Currency
DoCmd.Hourglass True
'SAVE RECORD
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20

Replace this with

If Me.Dirty Then
Me.Dirty = False
End If
'Then select all of "services" for this pt and for this insco# and
change
'values to new insco#, insaddress and insindex
'SET EARLIEST DATE FOR EFFECTIVE CHANGE
If Not IsNull(DMin("[Date_From]", "Services", "[patient ID#] = Forms!
[FInsuranceInfoEdit]![patient ID#] and Forms![FInsuranceInfoEdit]!
[SelectInsco]")) Then
Dt = DMin("[Date_From]", "Services", "[patient ID#] = Forms!
[FInsuranceInfoEdit]![patient ID#] and Forms![FInsuranceInfoEdit]!
[SelectInsco]") '??????
Else
MsgBox "No Services entered to correct"
DoCmd.Close acForm, "FInsuranceInfoEdit", acSaveYes

Use the default acSaveNo. This parameter controls whether to store
changes at the form object itself or not.

A few things to try:

Create a procedure to do the calculation and shorten the code for the
button like that:

Private Sub DoCalculation(ADate As Date)
'do the calculation here
End Sub

Private Sub Button25_Click()

On Local Error GoTo LocalError

Dim Dt As Variant

Dt = DMin("[Date_From]", _
"Services", _
"[patient ID#] = " & Me![patient ID#] & _
"AND [SelectInsco] = " & Me![SelectInsco]")

If IsNull(Dt) Then
MsgBox "No Services entered to correct"
DoCmd.Close acForm, Me.Name, acSaveNo
Else
DoCalculation Dt
End If

Exit Sub

LocalError:
'do error handling.

End Sub

Have you already run Compact and Repair?

mfG
--> stefan <--

Stefan:
"Create a procedure to do the calculation and shorten the code for the
button---"
Is there any reason that a long code event (not really that long)
should cause an event to fail & the app then crash?

Yes, I've run 'compact & repair' on a regular basis.
Richard
 
J

Jeanette Cunningham

Hi,
sorry but I don't have any idea why it would crash on close from the close
button, but not if you put a separate close button. We need more eyes to
look at this. If there are no other answers in a couple of day, repost as a
new thread.

Jeanette Cunningham



The first thought I have on this is that Access gets to the close command
before it has finished the calculation and this causes the crash.
One thing to try is to put these 2 lines directly before the DoCmd.Close
DoEvents
DoEvents

If that doesn't help, posting all the code for the click event of the
close
button would help us to help you.

Jeanette Cunningham

Jeanette,
Since the crash occurs even when I go thru the code line-by-line, I
don't think that your supposition is the answer. The code (somewhat
simplified for brevity) follows:private Sub Button25_Click()
On Error GoTo Err_Button25_Click
DoCmd.SetWarnings False

Dim MySQL As String, MySQL1 As String, MySQL2 As String, Dt As String,
i As Integer
Dim DB As DAO.Database, rst As DAO.Recordset, rst1 As DAO.Recordset,
rst2 As DAO.Recordset, rst3 As DAO.Recordset, MySQL3 As String
Dim rst4 As DAO.Recordset, Mysql4 As String, Mysql5 As String, MySQL6
As String, MySQL7 As String, cp As Currency, D As Currency
Dim Precharges As Currency, Answer As Date, Answer1 As String, FeeReg
As Currency

DoCmd.Hourglass True


'SAVE RECORD
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20

'Then select all of "services" for this pt and for this insco# and
change
'values to new insco#, insaddress and insindex

'SET EARLIEST DATE FOR EFFECTIVE CHANGE
If Not IsNull(DMin("[Date_From]", "Services", "[patient ID#] = Forms!
[FInsuranceInfoEdit]![patient ID#] and Forms![FInsuranceInfoEdit]!
[SelectInsco]")) Then
Dt = DMin("[Date_From]", "Services", "[patient ID#] = Forms!
[FInsuranceInfoEdit]![patient ID#] and Forms![FInsuranceInfoEdit]!
[SelectInsco]") '??????
Else
MsgBox "No Services entered to correct"
DoCmd.Close acForm, "FInsuranceInfoEdit", acSaveYes
DoCmd.Hourglass False
Exit Sub
End If
DoCmd.Beep

Answer = InputBox$("First Svc Date for this patient is " & Dt & ":" &
Chr(13) & Chr(10) & "Enter effective date of this insurer correction"
& Chr(13) & Chr(10) & "Enter in format mm-dd-yyyy", , Dt)

Me![Effective Policy Date] = Format(Answer, "mm-dd-yyyy")






'UPDATE SERVICES SO THAT MONETARY DATA IS BLANK IN RST
MySQL2 = "UPDATE DISTINCTROW SERVICES SET SERVICES.lineinsurer =
[Forms].[FInsuranceInfoEdit].[SelectInsco], " & _
"SERVICES.[InsIndex#] = [Forms].[FInsuranceInfoEdit].[PolicyType], " &
_
"SERVICES.AddIndex = [Forms].[FInsuranceInfoEdit].[InsAddress], " & _
"SERVICES.linecoinsurer = [Forms].[FInsuranceInfoEdit].
[SelectCoinsco], " & _
"SERVICES.[CoInsIndex#] = [Forms].[FInsuranceInfoEdit].[CoPolicyType],
" & _
"SERVICES.CoAddIndex = [Forms].[FInsuranceInfoEdit].[CoInsAddress], "
& _
"SERVICES.AnnDeductCovered = [Forms].[FInsuranceInfoEdit].
[AnnDeductCovered], " & _
"SERVICES.ProceduralDeduct = [Forms].[FInsuranceInfoEdit].[ProcedureCo-
pay], " & _
"SERVICES.OfficeProcedureAmt = [Forms].[FInsuranceInfoEdit].
[OfcProcedureCo-PayFee], " & _
"SERVICES.HospProcedureAmt = [Forms].[FInsuranceInfoEdit].
[HospProcedCo-PayFee], " & _
"SERVICES.PayCatID = [Forms]![FInsuranceInfoEdit].[PayCatID], " & _
"SERVICES.Precharges = 0, SERVICES.Charges = 0, SERVICES.[Charges adj]
= 0, " & _
"SERVICES.ChargesApproved = 0, SERVICES.AnnualDeduct = 0,
SERVICES.deductapplied = 0, SERVICES.ProcedureDeductApplied = 0, " & _
"SERVICES.PreAnticPay = 0, SERVICES.PreAnticPay1 = 0,
SERVICES.PreAnticPay2 = 0, SERVICES.AnticPay = 0, " & _
"SERVICES.PatientOwes = 0, SERVICES.AnticCopay = 0, SERVICES.CoPay =
0, SERVICES.QUamt = 0 " & _
"WHERE (((SERVICES![Patient ID#])=[Forms].[FInsuranceInfoEdit].
[Patient ID#]) " & _
"AND ((SERVICES.Date_From) >=[Forms].[FInsuranceInfoEdit].[Effective
Policy Date])); "

DoCmd.RunSQL MySQL2


'RST for correction is SET HERE

Set DB = CurrentDb()
MySQL = "SELECT DISTINCTROW Services.* " & _
"FROM Services " & _
"WHERE (Services.lineinsurer= " & Me![SelectInsco] & ") " & _
"AND (Services.[Patient ID#]= " & Me![Patient ID#] & ") " & _
"AND (Services.Date_From >= " & Me![Effective Policy Date] & ") " & _
"ORDER BY Services.INVLINNUM;"
Set rst = DB.OpenRecordset(MySQL, dbOpenDynaset)
g = rst.RecordCount
If g > 0 Then
'SET PRECHARGES & CHARGES
Dim Insurance_Co As String, CCode As String, Days As Integer,
Modifiers As Integer, Billyear As Integer, fil As String
'determine linnumber of item
'find data for DLookup--insurance co name


rst.MoveFirst
Do Until rst.EOF

If rst!Mod1 = "26" Or rst!Mod1 = "TC" Then
c = rst!CPTCode & rst!Mod1

ElseIf rst!Mod2 = "26" Or rst!Mod2 = "TC" Then
c = rst!CPTCode & rst!Mod2

Else: c = rst!CPTCode
End If

y = DatePart("yyyy", rst!Date_From)


x = rst!paycatID


Select Case Val(x) ' Test input.

'note that several cases are omitted from code for brevity


Case 1, 4, 10, 11 'Medicare type 'ELIMINATE #3-Managed Care

'normal fee comes before lopay = -1
'if regular pay line is null, then fill in prices before rest of line
finishes
If IsNull(DLookup("[fee]", "FeeSchedCare", "[CPTCode] = '" & c
& "' And [year] ='" & y & "' And [lopay] = 0 ")) Then
'seek record where cpt code = C & lopay = no
DoCmd.OpenForm "FFeeSchedCare", , , ("[CptCode] = '" & c & "'
And [year] ='" & y & "' And [lopay] = 0 ")
End If
rst.Edit
If rst![Place of svc] <> 11 Then

If Not IsNull(DLookup("[fee]", "FeeSchedCare", "[CPTCode]
='" & c & "' And [year] = '" & y & "' And [lopay] = -1 ")) Then

rst!Precharges = DLookup("[fee]", "FeeSchedCare",
"[CPTCode] ='" & c & "' And [year] = '" & y & "' And [lopay] = -1 ")

ElseIf IsNull(DLookup("[fee]", "FeeSchedCare", "[CPTCode]
='" & c & "' And [year] = '" & y & "' And [lopay] = -1 ")) Then

rst!Precharges = DLookup("[fee]", "FeeSchedCare",
"[CPTCode] = '" & c & "' And [year] ='" & y & "' And [lopay] = 0 ")

End If

ElseIf rst![Place of svc] = 11 Then

rst!Precharges = DLookup("[fee]", "FeeSchedCare",
"[CPTCode] = '" & c & "' And [year] ='" & y & "' And [lopay] = 0 ")
rst.update
End If



Case 9
Msg = "Enter value for this miscellaneous charge"
MsgBox Msg ' Display message.
Exit Sub
End Select
rst.MoveNext
Loop



'SET CHARGE
rst.MoveFirst
Do Until rst.EOF
rst.Edit
If rst!Units = 1 Then
If rst!Mod1 = "50" Or rst!Mod2 = "50" Or rst!Mod3 = "50" Or
rst!Mod4 = "50" Then
rst!Charges = rst![Precharges] * 1.5
ElseIf rst!Mod1 = "53" Or rst!Mod2 = "53" Or rst!Mod3 = "53"
Or rst!Mod4 = "53" Then
rst!Charges = rst![Precharges] * 0.5
Else: rst!Charges = rst!Precharges
End If

ElseIf rst!Units <> 1 Then
rst![Charges] = rst![Precharges] * (rst!Units)
End If
rst.update
rst.MoveNext
Loop

The rest of these calculation steps are simply other examples of If--
Then and Do---loop sequences to perform calculations to set values of
rst fields. (Details have been omitted)


'Step2 'applydeduct 'sets [preanticpay]

'Step 3 apply co-pay

'Step4 'SetCoPayProcedural
'sets value of copayment for procedures for certain insurers

' setpercentpay 'step5


'Step6
'This sets [PatientOwes] and [AnticCoPay]


'Set QU value Step 7


'billdetailsupdate Step8

'finalize Step9


DoCmd.SetWarnings False
rst.MoveFirst
Do Until rst.EOF
MySQL7 = "UPDATE DISTINCTROW TBillDetails SET TBillDetails.InitBD1 =
Null, TBillDetails.LastBD1 = Null "
MySQL7 = MySQL7 & "WHERE TBillDetails.linenum = " & rst!LineNum & ";"

DoCmd.RunSQL MySQL7
rst.MoveNext
Loop
DoCmd.SetWarnings True
End If
rst.Close

DoCmd.SetWarnings True
DoCmd.Hourglass False
'THIS IS WHERE APPLICATION CRASHES
DoCmd.Close


Exit_Button25_Click:
Exit Sub

Err_Button25_Click:
MsgBox Error$
Resume Exit_Button25_Click
End Sub
 
S

Stefan Hoffmann

hi Richard,

"Create a procedure to do the calculation and shorten the code for the
button---"
Is there any reason that a long code event (not really that long)
should cause an event to fail & the app then crash?
Length of code doesn't lead to a failure, if it didn't exceed the
language specifications.
It is just code coding style. Makes reading easier, as I have to admit,
that I don't see a clear control flow in your code on the first glance.

And as experience tells us: rewritten code is better code :)
Yes, I've run 'compact & repair' on a regular basis.
Then corruption is not your problem.


mfG
--> stefan <--
 

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