473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

My code wont work Why?

I have this code behind a command button but it doesn't delete the record.
If vbNo = MsgBox("Are you sure you want to save this new record?", 4) Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
If vbYes = MsgBox("Do you want to input another record?", 4) Then
[DocNametxt].SetFocus
End If
DoCmd.Close

I've also tried
DoCmd.RunCommand acCmdDeleteRecord
But this didn't work either
Anyone help me with why?
TIA
Tony Williams
Nov 12 '05 #1
2 2915
Hi Tony,

I'm assuming that you're using Access97 or newer here, correct?
I hate that Access95 DoMenuItem crap ... try using the form's "Dirty"
property instead ... like this:

If Msgbox("Are you sure you want to save this new record?", vbYesNo) =
vbYes Then
'If the user clicks Yes, this "saves" the current record
Me.Dirty = False

Else
'If the user clicks No, this "un-does" the changes to the current
record.
Me.Undo

'Now, "nest" your other "If" statement here ... so that this msg is only
displayed if the user clicks No in the first msg.
If MsgBox("Would you like to input something else?", vbYesNo) =
vbYes Then
Me.[DocNametxt].SetFocus
Else
DoCmd .Close
End If

End If
--
HTH,
Don
=============================
Use My*****@Telus.Net for e-mail
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.
=============================

"Tony Williams" <tw@tcp.invalid> wrote in message
news:c4**********@hercules.btinternet.com...
I have this code behind a command button but it doesn't delete the record.
If vbNo = MsgBox("Are you sure you want to save this new record?", 4) Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
If vbYes = MsgBox("Do you want to input another record?", 4) Then
[DocNametxt].SetFocus
End If
DoCmd.Close

I've also tried
DoCmd.RunCommand acCmdDeleteRecord
But this didn't work either
Anyone help me with why?
TIA
Tony Williams

Nov 12 '05 #2
Thanks Don works just fine I'm using A20000
Tony
"Don Leverton" <le****************@telusplanet.net> wrote in message
news:O%3bc.48$B16.37@edtnps89...
Hi Tony,

I'm assuming that you're using Access97 or newer here, correct?
I hate that Access95 DoMenuItem crap ... try using the form's "Dirty"
property instead ... like this:

If Msgbox("Are you sure you want to save this new record?", vbYesNo) =
vbYes Then
'If the user clicks Yes, this "saves" the current record
Me.Dirty = False

Else
'If the user clicks No, this "un-does" the changes to the current
record.
Me.Undo

'Now, "nest" your other "If" statement here ... so that this msg is only displayed if the user clicks No in the first msg.
If MsgBox("Would you like to input something else?", vbYesNo) =
vbYes Then
Me.[DocNametxt].SetFocus
Else
DoCmd .Close
End If

End If
--
HTH,
Don
=============================
Use My*****@Telus.Net for e-mail
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.
=============================

"Tony Williams" <tw@tcp.invalid> wrote in message
news:c4**********@hercules.btinternet.com...
I have this code behind a command button but it doesn't delete the record. If vbNo = MsgBox("Are you sure you want to save this new record?", 4) Then DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
If vbYes = MsgBox("Do you want to input another record?", 4) Then
[DocNametxt].SetFocus
End If
DoCmd.Close

I've also tried
DoCmd.RunCommand acCmdDeleteRecord
But this didn't work either
Anyone help me with why?
TIA
Tony Williams


Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Oliver Spiesshofer | last post by:
Hi, I have a script that calls an fopen() on an external URL. I can run the script from the server as an url fine. When however the script should be run from crontab, it does not work. I get ...
242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
19
by: Allen Thompson | last post by:
sorry for the simple question, haven't done this in a while. when I use the following script it keeps displaying the value of "x" like a string. for example, if I type the number 7 in the prompt,...
1
by: jparker | last post by:
I have been working with ASP classic on this current project im involved in. Well the problem im facing now is there is a page where a flash movie should play in a particular section on the page...
3
Frinavale
by: Frinavale | last post by:
Hi there, I am currently behind a firewall that wont let me send emails. As a result my smtpClient.send(emailMessage) wont work on my IIS but this method does work through the VisualStudio...
1
by: Jia Lu | last post by:
Hello I have a program that can telnet to a host. But I cannot understand from part, can anyone explain it to me? Thank you very much. import sys, posix, time
66
by: Jon Skeet [C# MVP] | last post by:
I'm sure the net will be buzzing with this news fairly soon, but just in case anyone hasn't seen it yet: Microsoft are going to make the source code for the .NET framework (parts of it,...
36
by: The Frog | last post by:
Hi Everyone, I am trying to find a solution for handling zipped data without the need to ship / install any DLL files with the database. Does anybody know of code to handle ZIP files that does...
4
by: Jeremy | last post by:
Looks like this is either too obvious for anyone to address, or it just isn't done by anyone. There was a question in early sep this year that no one replied to, and I don't find any other...
0
by: sourpo | last post by:
wonder if anyone can help... I have access db with a whole lot of vb code... If i use access 2000 it works perfectly but when using 2003 it doesn't work properly. The db copies outlook mailboxes......
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.