Hi Everybody
I hope you can help.
2 related questions.
1. I am looking for a way to replace the confusing message box that comes up when a user trys to
open a form without putting data in it.
ie ..Syntax Error(Missing Operator) In queryexpression '[WriteID="
which seems to puzzle users
I would like to replace that with something more user friendly.
The code I am currenly using is:
Private Sub txtRe_DblClick(Cancel As Integer)
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
On Error GoTo Err_txtRe_DblClick
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmSupplierWriteText"
stLinkCriteria = "[WriteID]=" & Me![WriteID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_txtRe_DblClick:
Exit Sub
Err_txtRe_DblClick:
MsgBox Err.Description
Resume Exit_txtRe_DblClick
End Sub
2. I would also like to replace the message "You are about to delete 1 record(s) If you click Yes
you won't be able to undo this operation. Are you sure you want to delete these records.
If the user says "No" then "The DoMenuItem was cancelled". Not very user friendly. I am looking to
replace this with something better. The code I am using at the moment is:
Private Sub delete_Click()
On Error GoTo Err_delete_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_delete_Click:
Exit Sub
Err_delete_Click:
MsgBox Err.Description
Resume Exit_delete_Click
End Sub
Grateful for any Help
Smiley Bob 5 5023
The first error message occurs when WriteID is null. Because there is no
number at all, the link criteria string becomes just:
WriteID =
which is a nonsense that Access cannot understand. To avoid that, test for
Null before assigning the string:
If IsNull(Me.WriteID) Then
Beep
Else
stDocName = "frmSupplierWriteText"
stLinkCriteria = "[WriteID]=" & Me![WriteID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
The 2nd message is Access' way of notifying you (the programmer) that the
action you asked for did not happen. If you temporarily comment out the
error handler line ("On Error Goto..."), you will be able to see the message
number, and then just ignore that number in your error handler. This example
shows how to ignore Error 2501:
Err_delete_Click:
If Err.Number <> 2501 Then
MsgBox Err.Description
End If
Resume Exit_delete_Click
End Sub
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Bob" <sm*******@hotmail.com> wrote in message
news:hn********************************@4ax.com... Hi Everybody
I hope you can help.
2 related questions.
1. I am looking for a way to replace the confusing message box that comes
up when a user trys to open a form without putting data in it. ie ..Syntax Error(Missing Operator) In queryexpression '[WriteID=" which seems to puzzle users
I would like to replace that with something more user friendly. The code I am currenly using is:
Private Sub txtRe_DblClick(Cancel As Integer) DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 On Error GoTo Err_txtRe_DblClick
Dim stDocName As String Dim stLinkCriteria As String
stDocName = "frmSupplierWriteText" stLinkCriteria = "[WriteID]=" & Me![WriteID] DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_txtRe_DblClick: Exit Sub Err_txtRe_DblClick: MsgBox Err.Description Resume Exit_txtRe_DblClick End Sub
2. I would also like to replace the message "You are about to delete 1
record(s) If you click Yes you won't be able to undo this operation. Are you sure you want to delete
these records. If the user says "No" then "The DoMenuItem was cancelled". Not very user
friendly. I am looking to replace this with something better. The code I am using at the moment is:
Private Sub delete_Click() On Error GoTo Err_delete_Click DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70 Exit_delete_Click: Exit Sub Err_delete_Click: MsgBox Err.Description Resume Exit_delete_Click End Sub
Grateful for any Help
Smiley Bob
On Mon, 26 Apr 2004 09:25:09 +0800, "Allen Browne" <Al*********@SeeSig.Invalid> wrote:
Thanks for that Allen. The First code works well. I now have my OWN message box that gives the user
The instuction "You MUST Enter a reference Title"
The 2nd one I don't think I explained myself correctly. What I am looking to achieve is to REPLACE
the message "You are about to delete 1 record(s) If you click Yes you won't be able to undo this
operation. Are you sure you want to delete these records. WITH a message box that says "Are your
sure you want to delete this Letter" and a Yes/No.
If the user selects Yes Message Box "Letter Deleted " and it deletes.
If the user selects No Message Box "Letter Not Deleted " and it remains
Thanks
Smiley Bob
Okay, Bob. Use the BeforeDelConfirm event of the form if you wish to pop up
your own message box. Example from the help file:
Private Sub Form_BeforeDelConfirm(Cancel As Integer, _
Response As Integer)
' Suppress default Delete Confirm dialog box.
Response = acDataErrContinue
' Display custom dialog box.
If MsgBox("Delete this record?", vbOKCancel) = vbCancel Then
Cancel = True
End If
End Sub
Please be aware, though, that the default message accurately notifies the
user about the number of records being deleted (since more than one can be
selected in a datasheet or continuous form), and if related records will be
deleted thorugh a cascading delete. These two issues are not exposed to you
for your custom message, and it could take quite a bit more code to achieve
that.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Bob" <sm*******@hotmail.com> wrote in message
news:lm********************************@4ax.com... On Mon, 26 Apr 2004 09:25:09 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote: Thanks for that Allen. The First code works well. I now have my OWN
message box that gives the user The instuction "You MUST Enter a reference Title"
The 2nd one I don't think I explained myself correctly. What I am looking
to achieve is to REPLACE the message "You are about to delete 1 record(s) If you click Yes you
won't be able to undo this operation. Are you sure you want to delete these records. WITH a message
box that says "Are your sure you want to delete this Letter" and a Yes/No.
If the user selects Yes Message Box "Letter Deleted " and it deletes. If the user selects No Message Box "Letter Not Deleted " and it remains
Thanks
Smiley Bob
Bob wrote...
"Bob" <sm*******@hotmail.com> wrote in message
news:lm********************************@4ax.com... On Mon, 26 Apr 2004 09:25:09 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote: Thanks for that Allen. The First code works well. I now have my OWN
message box that gives the user The instuction "You MUST Enter a reference Title"
The 2nd one I don't think I explained myself correctly. What I am looking
to achieve is to REPLACE the message "You are about to delete 1 record(s) If you click Yes you
won't be able to undo this operation. Are you sure you want to delete these records. WITH a message
box that says "Are your sure you want to delete this Letter" and a Yes/No.
If the user selects Yes Message Box "Letter Deleted " and it deletes. If the user selects No Message Box "Letter Not Deleted " and it remains
Thanks
Smiley Bob
Bob,
I use the following code on my Delete buttons "on Click Event Procedure: you
may wish to change the error handling to reflect your own.
Hope this help's
Cheers,
Dave
' ---------- Code Starts ----------
Private Sub cmdDeleteRecord_Click()
' Button: Delete Record
On Error GoTo ErrorHandler
DoCmd.SetWarnings False
If MsgBox("You are about to delete the current record" & Chr(13) & " " &
_
Chr(13) & "If you select 'Yes' you will not be able to UNDO this
action;" _
& Chr(13) & " " & Chr(13) & "it will be immediate and irreversible!" _
& Chr(13) & " " & Chr(13) & "Do you wish to continue?", vbQuestion + _
vbYesNo + vbDefaultButton2, "Delete?") = vbYes Then
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
Me!cboFind.Requery
End If
ExitProcedure:
Exit Sub
ErrorHandler:
If Err = 2046 Then 'Command not available
MsgBox "No Record to Delete, canceling delete action."
ElseIf Err = 2501 Then ' Action was cancelled
Resume Next
Resume ExitProcedure
Else
Select Case Err.Number
Case Else ' Any unexpected error.
Call LogError(Err.Number, Err.Description,
"cmdDeleteRecord_Click()")
End Select
End If
End Sub
' ---------- Code Ends ----------
On Mon, 26 Apr 2004 14:50:59 GMT, "Dave Brydon" <db*****@ns.sympatico.ca> wrote:
Thanks Guys! Both of those worked well.
I love this NG
Bob Bob wrote... "Bob" <sm*******@hotmail.com> wrote in message news:lm********************************@4ax.com.. . On Mon, 26 Apr 2004 09:25:09 +0800, "Allen Browne" <Al*********@SeeSig.Invalid> wrote: Thanks for that Allen. The First code works well. I now have my OWN
message box that gives the user The instuction "You MUST Enter a reference Title"
The 2nd one I don't think I explained myself correctly. What I am looking to achieve is to REPLACE the message "You are about to delete 1 record(s) If you click Yes you won't be able to undo this operation. Are you sure you want to delete these records. WITH a message box that says "Are your sure you want to delete this Letter" and a Yes/No.
If the user selects Yes Message Box "Letter Deleted " and it deletes. If the user selects No Message Box "Letter Not Deleted " and it remains
Thanks
Smiley Bob
Bob,
I use the following code on my Delete buttons "on Click Event Procedure: you may wish to change the error handling to reflect your own. Hope this help's
Cheers,
Dave
' ---------- Code Starts ---------- Private Sub cmdDeleteRecord_Click() ' Button: Delete Record On Error GoTo ErrorHandler DoCmd.SetWarnings False
If MsgBox("You are about to delete the current record" & Chr(13) & " " & _ Chr(13) & "If you select 'Yes' you will not be able to UNDO this action;" _ & Chr(13) & " " & Chr(13) & "it will be immediate and irreversible!" _ & Chr(13) & " " & Chr(13) & "Do you wish to continue?", vbQuestion + _ vbYesNo + vbDefaultButton2, "Delete?") = vbYes Then DoCmd.RunCommand acCmdSelectRecord DoCmd.RunCommand acCmdDeleteRecord Me!cboFind.Requery End If
ExitProcedure: Exit Sub ErrorHandler:
If Err = 2046 Then 'Command not available MsgBox "No Record to Delete, canceling delete action." ElseIf Err = 2501 Then ' Action was cancelled Resume Next Resume ExitProcedure Else
Select Case Err.Number Case Else ' Any unexpected error. Call LogError(Err.Number, Err.Description, "cmdDeleteRecord_Click()") End Select
End If
End Sub ' ---------- Code Ends ---------- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: pembed2003 |
last post by:
Hi all,
I asked this question in the C group but no one seems to be interested
in answering it. :-( Basically, I wrote a search and replace function
so I can do:
char source = "abcd?1234?x";...
|
by: Eric Lilja |
last post by:
Hello, I had what I thought was normal text-file and I needed to locate a
string matching a certain pattern in that file and, if found, replace that
string. I thought this would be simple but I had...
|
by: Bob |
last post by:
Hi Everybody
I hope you can help.
2 related questions.
1. I am looking for a way to replace the confusing message box that comes up when a user trys to
open a form without putting data in...
|
by: Matt |
last post by:
Hi folks. Can you help with some questions?
I gather that some types supported by g++ are nonstandard but have been
proposed as standards.
Are the long long and unsigned long long types still...
|
by: pembed2003 |
last post by:
Hi all,
I need to write a function to search and replace part of a char*
passed in to the function. I came up with the following:
char* search_and_replace(char* source,char search,char*...
|
by: BBM |
last post by:
This is so bizarre I hesitate to post it, but I need to get this working.
My code looks like this...
Private Const cmdTestResourcesSel = "SELECT * FROM TResources" & _
" WHERE Scenario =...
|
by: Rico |
last post by:
I'm moving some queries out of an Access front end and creating views out of
them in SQL Server 2005 express. In some of the numeric fields, I use nz
quite often, ( i.e. nz(,0)) to return a zero...
|
by: Roy W. Andersen |
last post by:
Hi,
I need to do some replace-calls on certain strings in order to replace
smiley glyphs and other keywords with graphical icons on the client.
Unfortunately, my knowledge of regular expressions...
|
by: jacob navia |
last post by:
In my "Happy Christmas" message, I proposed a function to read
a file into a RAM buffer and return that buffer or NULL if
the file doesn't exist or some other error is found.
It is interesting...
|
by: Stephen Horne |
last post by:
I've been using Visual C++ 2003 for some time, and recently started
working on making my code compile in GCC and MinGW. I hit on lots of
unexpected problems which boil down to the same template...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |