I have a database used by our communications center which allows dispatchers to
enter incidents that occur. On this form there is a Case ID which when double
clicked assigns a new case ID to the incident. I did not create this database,
and because I'm not too familiar with vba coding I'm not exactly sure what to
do. What we want is to have the Case ID start at 1 everyday instead of yearly.
The following is the code I found when the Case ID is double clicked. If more
information is needed I can try to upload the database to the Assistance Needed
folder.
-----------------------
Private Sub PS_Police_case_id_DblClick(Cancel As Integer)
Dim db As DAO.Database
Dim Rec As DAO.Recordset
Dim addDate
Dim addTime
Dim CASE_Num As Double
Dim intlockretry As Integer
Const Lock_Retry_Max = 7
intlockretry = 0
Set db = CurrentDb() ' Return reference to current database.
Set Rec = db.OpenRecordset("PS_CaseID_Next_tbl", , dbDenyWrite) 'Open the
Next Help Number table
'and place an exclusive
lock on it
With Rec
.Edit
![NEXTCASENO] = ![NEXTCASENO] + 1 'Increment the Help Number
CASE_Num = Rec![NEXTCASENO] 'Assign new Help Number to a work variable
.Update 'Save changes to record.
End With
Rec.Close 'close the table
Set db = Nothing 'disassociate the reference
' Me.PS_Police_Case_id = "09 - " & Right("00000" & [CASE_Num], 5) 'Assign the
new Help Number in the work variable to the form field
Me.PS_Police_Case_id = Right(Year(Date), 2) & " - " & Right("00000" &
[CASE_Num], 5) 'Assign the new Help Number in the work variable to the form
field
Me.PS_Police_Case_id.BackColor = 11796479
'MsgBox (Me.Dirty) 'IMPORTANT KEEP THIS - It determines whether your form is
dirty or not
'example: true means the record has changed it should
show "False"
End Sub
-------------------
Any help is appreciated!!
Thanks!
Katrina
Selasa, 31 Januari 2012
[MS_AccessPros] Question on VBA Coding for double click field
__._,_.___
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar