Command Button Message Box

Command Button Message Box

am 11.01.2008 20:59:41 von u36225

I have a command button “AddIncident”. I would like to make it so that it
will not add the record to the database if textbox “Type” is empty. I also
would like to add a message that will prompt the user with the message “You
must enter incident Type” when textbox “Type” is empty and the “AddIncident”
button is pressed.

Thank You

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-ac cess/200801/1

Re: Command Button Message Box

am 11.01.2008 21:28:25 von manningfan

On Jan 11, 2:59 pm, "pushrodengine via AccessMonster.com"
wrote:
> I have a command button "AddIncident". I would like to make it so that it
> will not add the record to the database if textbox "Type" is empty. I also
> would like to add a message that will prompt the user with the message "You
> must enter incident Type" when textbox "Type" is empty and the "AddIncident"
> button is pressed.
>
> Thank You
>
> --
> Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.asp x/databases-ms-access/2008...

In the OnClick event of the button, do something like:

if me.checkbox = -1 then
msgbox "Check the box, dummy!"
exit sub
else
'Do whatever you want the button to do
end if

NOTE: The above will need some tweaking, I'm, just going off the top
of my head. But it should be about 90% useable as written.

Re: Command Button Message Box

am 11.01.2008 21:49:59 von fredg

On Fri, 11 Jan 2008 19:59:41 GMT, pushrodengine via AccessMonster.com
wrote:

> I have a command button ´AddIncident¡. I would like to make it so that it
> will not add the record to the database if textbox ´Type¡ is empty. I also
> would like to add a message that will prompt the user with the message ´You
> must enter incident Type¡ when textbox ´Type¡ is empty and the ´AddIncident¡
> button is pressed.
>
> Thank You

What does the command button actually do?
any way....
Code the Form's BeforeUpdate event:

If IsNull([Type]) Then
MsgBox ´You must enter incident Type when textbox 'Type' is empty and
the 'AddIncident' button is pressed."
Cancel = true
End If




The
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Re: Command Button Message Box

am 11.01.2008 22:04:12 von u36225

>What does the command button actually do?

This button is the Add New Record command button.

The problem I'm having is that blank records can be add to the database. The
way to prevent this careless pressing of the AddIncident button is to require
the user to enter a type into the "Type" textbox.

No Type = No Add New Record = Message Box.

Thanks

--
Message posted via http://www.accessmonster.com

Re: Command Button Message Box

am 11.01.2008 22:21:12 von u36225

I got it using a combination of both codes.

Thank you ManningFan and fredg.

--
Message posted via http://www.accessmonster.com

Re: Command Button Message Box

am 12.01.2008 18:05:46 von Susan Bricker

Another method would be to not enable the user to click on the command
button (enable=false) until the requisite fields are populated. You
could change the command button's attribute in the AfterUpdate routine
of the input fields you are concerned about. Then the command button
would only be accessible AFTER the data had been entered on the screen.

I like to do it this way to prevent the user from doing anything I don't
want them to do before I am ready for them to do it.

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***

Re: Command Button Message Box

am 12.01.2008 19:12:51 von arch

On 12 Jan 2008 17:05:46 GMT, Susan Bricker
wrote:

>Another method would be to not enable the user to click on the command
>button (enable=false) until the requisite fields are populated. You
>could change the command button's attribute in the AfterUpdate routine
>of the input fields you are concerned about. Then the command button
>would only be accessible AFTER the data had been entered on the screen.
>
>I like to do it this way to prevent the user from doing anything I don't
>want them to do before I am ready for them to do it.
>
>Regards,
>SueB
>

That's my preference as well. I think it makes for a more "polished"
application.

Re: Command Button Message Box

am 15.01.2008 04:14:41 von John Mishefske

Susan Bricker wrote:
> Another method would be to not enable the user to click on the command
> button (enable=false) until the requisite fields are populated. You
> could change the command button's attribute in the AfterUpdate routine
> of the input fields you are concerned about. Then the command button
> would only be accessible AFTER the data had been entered on the screen.
>
> I like to do it this way to prevent the user from doing anything I don't
> want them to do before I am ready for them to do it.

I'm interested in this technique too but how do you provide feedback to
the user who can't determine why the button isn't enabled?

I suppose you can indicate required data entry with a special backcolor
or (like a web form) a special character next to the field (yecchh).

Or a label with explicit instructions.

--
'--------------------------
' John Mishefske
' UtterAccess Editor
' Microsoft MVP 2007, 2008
'--------------------------