Change Access Delete Messages (1 Viewer)

patkeaveney

Registered User.
Local time
Today, 15:44
Joined
Oct 12, 2005
Messages
75
I want to replace the standard Access Delete Messages, with my own.
I know how to use set warnings.
I have cascading deletes option turned on.
I need to tell if a record I am about to delete has associated records, so i can change the access message to a more user friendly one.

eg

"Deleting this Schedule will remove all students booked on this course. Do you want to delete this Record"

I want to display a different message if there are no associated records.

"Are you sure you want to delete this Schedule"

Any help Please
 

Telecom

Registered User.
Local time
Today, 10:44
Joined
Oct 28, 2004
Messages
42
You can use something like this...

Code:
Dim strMsgBoxMsg As String
Dim strMsgBoxStyle As String
Dim strMsgBoxTitle As String
Dim strMsgBoxResponse As String

strMsgBoxMsg = "Are you sure you want to delete this Schedule?" 'Define Msg
strMsgBoxStyle = vbOKCancel Or vbDefaultButton2 'Define Buttons
strMsgBoxTitle = "<Enter Title of Msg Box Here>" 'Define Title
strMsgBoxResponse = MsgBox(strMsgBoxMsg, strMsgBoxStyle, strMsgBoxTitle) 'Display Message

If strMsgBoxResponse = vbOK Then
'Code Here...
Else
'Code Here...
End If
 

patkeaveney

Registered User.
Local time
Today, 15:44
Joined
Oct 12, 2005
Messages
75
telecom thanks for your speedy reply.

I can do the message bit, the part I am having trouble with is knowing if any records are associated with the record I want to delete, so i can display a user friendly message and not the access one which says (relationships that specify cascading deletes are about to cause i record in this table and in related tables to be deleted).
Some records dont have related records, so I want to display a different message

thanks
 

Telecom

Registered User.
Local time
Today, 10:44
Joined
Oct 28, 2004
Messages
42
Do you know which tables you wish to specifically check for an associated record?

If so, you can do a DCount.

In my Example below you want to check the tbl_Depts table to make sure you're not deleting a record that exists tbl_Employees.

Table: tbl_Depts
Key Field: fld_Dept_ID
2nd Field: fld_Dept_Name

2nd Table to check against
Table: tbl_Employees
Key Field: fld_Employee_ID
2nd Field: fld_Dept_ID

Form: frm_Employee_Info
Form Control to check against: txt_fld_Dept_ID or Forms![frm_Employee_Info]![txt_fld_Dept_ID]

Code:
'Declare DIMs
Dim intRecordCount as Integer

intRecordCount = 0 'Default RecordCount to 0
intRecordCount = DCount = "[fld_Dept_ID]", "tbl_Depts", "[fld_Dept_ID]=Forms![frm_Employee_Info]![txt_fld_Dept_ID]") 'Counts based on DCount Criteria

If intRecordCount > 0 Then 'Checks to see if there is more then one record
'More then 1 record...Code Here...
Else
'0 Records here...Code Here...
End If

Not sure if that is what you're looking for...
 

patkeaveney

Registered User.
Local time
Today, 15:44
Joined
Oct 12, 2005
Messages
75
Thanks Telecom

That is exactly what I wanted

Many Thanks again
 

Users who are viewing this thread

Top Bottom