View Full Version : help regarding msgbox


dk-
09-03-2004, 12:18 PM
I'm not that good of an access person and writing codes but if anyone would help me w/ this i'd greatly appreciated it!

On my form I made a save button and to ensure everything that is entered on the form is correct I tried setting up a macro that has a msgbox that prompts the user "Is everything correct"

Problem is the msgbox only has OK and I want yes or no. How would i create one that has what I want. If clicked "yes" it would save and "no" nothing happens.

Thanks again.

sfreeman@co.mer
09-07-2004, 04:32 PM
I know macros are much easier to use, but they are inferior to writing some basic VBA. You could create a command button on your form called 'SaveCommandButton', and in the OnClick Event paste the following code.

************************************************** *******
Private Sub SaveCommandButton_Click()
On Error GoTo Err_SaveCommandButton_Click

If MsgBox("Is everything correct?", vbYesNo, "Record OK") = vbYes Then DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_SaveCommandButton_Click:
Exit Sub

Err_SaveCommandButton_Click:
MsgBox Err.Description
Resume Exit_SaveCommandButton_Click

End Sub

************************************************** *******
If you click Yes, the record is saved. If you click No nothing happes.
HTH :D

Rich
09-08-2004, 12:08 AM
Your code is in the wrong place, incomplete and uses the obsolete DoMenuItem.
The best place to confirm changes is the BeforeUpdate Event of the form, there's an example here
http://www.access-programmers.co.uk/forums/showthread.php?t=72380

sfreeman@co.mer
09-08-2004, 08:48 AM
OK, Jagger, nice attitude.

1) Let's see, Code in the wrong place... hmmmm, Command Button .... OnClick, gee, seems like the right place to me....

2) Incomplete. OK we can add:

'***********************
'Code by RICH, the ONE
'***********************

NOW, it's complete.

3) Using the 'Obsolete' DoMenuItem:

Obsolete - Out of Date, Outdated, archaic, old fashion, outmoded
Antonym - cool, hip, now, happening, The One

Yeah, you got me you super-happening coder. [Funny, it seems to work per his spec - go figure]

:)

Rich
09-08-2004, 09:40 AM
I'm not sure why you've decided to respond with sarcasm, if you think your code is ok then use it.

sfreeman@co.mer
09-08-2004, 10:02 AM
Responded in kind to your post. And, I do use my own code, including DoMenuItem where appropriate.

Rich
09-08-2004, 10:10 AM
OK. take your head out of the sand and search here for DoMenuItem, and incidentally my response was not sarcastic. If you want to use obsolete methods then carry on but don't get arsey when a member here points it out

KenHigg
09-08-2004, 10:14 AM
Quite a scuffle over a 5 day old post from a 1 time post'r...

kh

sfreeman@co.mer
09-08-2004, 01:53 PM
Thanks for brightening my day! ;) And, by all means, please continue pointing out all perceived flaws... :)