I'm trying to figure out exactly what is causing the crash. I thought it
was just when I updated/added a transaction, but yesterday it happened
without that. I can open my form and close it without problems, but it
often freezes on me if I added the transaction. The following is the code
that happens:
Private Sub btnSave_Click()
Dim patkey As String, oldMASTER As String, MsgChoice As Variant
'do something to save the record, then clear things for another...
patkey = [MASTER] & "." & VisitChoice
oldMASTER = [MASTER]
MsgChoice = MsgBox("Patkey: " & patkey & vbCrLf & "ProcCode: " &
NewProcCode & vbCrLf & "Amt: " & NewAmt & vbCrLf & _
"Loc: " & NewLOC & vbCrLf & "Prov: " &
NewProvider, vbOKCancel + vbCritical, "Confirm that this is correct!")
If MsgChoice Then
Call ApplyPmt([MASTER], VisitChoice, NewProcCode, Trmt, NewAmt,
NewProvider, NewLOC) '\in Module1
Call UpdateDemog([MASTER], NewAmt) '/
'MsgBox "back from update"
End If
HideInput
If MsgChoice Then
Me.Requery 'I _think_ this is what re-sets the VisitChoice query
Me.Refresh
End If
MASTER.SetFocus
' DoCmd.FindRecord oldMASTER
'for some reason it won't let me exit the form except when it does...
End Sub
Sub ApplyPmt(inpORNUM, Vst, PmtType, PmtTrCode, PmtAmt, Prov, Place)
'started 1/2/05
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim fld As Field
Set db = CurrentDb()
Set rs = db.OpenRecordset("NewTransactionList")
rs.AddNew
rs!ORNum = inpORNUM '3.10.05 changed for NewTransactionList
Table
rs!Visit = Vst
rs!KEY = UCase(inpORNUM) & "." & Vst
rs!SYSDATE = Format(Date, "mm/dd/yyyy")
rs!TRDATE = Format(Date, "mm/dd/yyyy")
rs!PROCCODE = PmtType
rs!QTY = 1
rs!AMT = Format(PmtAmt, "###0.00")
rs!DRNO = Prov 'ProvID
rs!LOCNO = Place 'POS
rs!TRCode = PmtTrCode 'for payment,charge,adjustment, etc
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
Sub UpdateDemog(inpORNUM, Pmt)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim fld As Field
Set db = CurrentDb()
Dim OldBal As Single, NewBal As Single
Dim FoundIt As Boolean
FoundIt = False
Set rs = db.OpenRecordset("NewDemog") 'SELECT DEMOG.* FROM Demog WHERE
DEMOG.MASTER = 'inpORNUM'") '2.27.05
rs.MoveFirst
Do ' is there any
chance this will work??? 2.22.05
If rs!MASTER = inpORNUM Then
FoundIt = True
OldBal = rs!BALANCE
NewBal = OldBal + Pmt 'if Pmt, should be a neg
number
'if Adj,
also neg
'if
charge, should be positive
rs.Edit
rs!BALANCE = Format(NewBal, "##,##0.00")
'MsgBox "Bal: " & rs!BALANCE & vbCrLf & "NB " & NewBal
rs.Update
End If
rs.MoveNext '("Master = " & [inpORNUM])
If FoundIt And rs!MASTER <> inpORNUM Then
'MsgBox "moving out of loop" & vbCrLf & rs!MASTER
Exit Do 'I think this breaks the loop when
rs!master changes....
End If
Loop Until rs.EOF '!MASTER <> [inpORNUM]
Set rs = Nothing
Set db = Nothing
End Sub
Private Sub HideInput()
Me.VisitChoice.Value = Null
[Child26].Visible = False
setfields False
MASTER.SetFocus
BtnSave.Enabled = False
BtnSave.Visible = False
BtnCancel.Visible = False
End Sub
Sub setfields(onoff As Boolean)
NewVisit.Visible = onoff
NewVisit.Value = Null
NewLOC.Visible = onoff
NewLOC.Value = Null
NewProvider.Visible = onoff
NewProvider.Value = Null
NewProcCode.Visible = onoff
NewProcCode.Value = Null
NewAmt.Visible = onoff
NewAmt.Value = Null
Trmt.Visible = onoff
Trmt.Value = Null
TrtmtCode_Label.Visible = onoff
Label50.Visible = onoff
Label52.Visible = onoff
Label54.Visible = onoff
Label59.Visible = onoff
Label61.Visible = onoff
End Sub
These are <I think> the relevant routines. The only other think I can
think of that happens is the requery of the "VisitChoice" query, which is
a query for a combobox.
Every time I quit/crash, a copy of my database is saved as db2.mdb,
db3.mdb, etc. I'm not sure that is relevant.
Thanks for your help. I, too, am worried.
Steve
Allen said:
After you update a recordset: in code? or manually in a form?
What code is running? Post the event procedure.
It is important to solve this, Steve, because crashing out of Access is a
fairly good way of corrupting the database.