How to have a user click okay/decline on a form to continue my cod

  • Thread starter Thread starter Southern at Heart
  • Start date Start date
S

Southern at Heart

I am looping through data, and after presenting it to the user, I simply need
my code to 'wait' for the user to either click acept or decline on the form,
and then my code will continue...
can this be done?
 
....To add for further understanding of my problem, my code needs this users
input maybe a dozen times, clicking accept or decline, as it moves thru the
data changing what the user wishes...
 
....The more I search for this, the more I'm finding it can't be done.
Actually, it's not just a 'accept/decline' input, but a 3 option input I'm
needing from the user
 
Well, it's unusual code, and the user uses it to go through a lot of data and
quickly makes changes, so I do need the continual input.

I think I see what you're saying: instead of having the input on the same
form, have it on a different popup form that is called from the first. Great
idea!
thanks.
 
I am looping through data, and after presenting it to the user, I simply need
my code to 'wait' for the user to either click acept or decline on the form,
and then my code will continue...
can this be done?

Code execution will wait for a msgbox to be clicked.
You can have as many MsgBox() functions as you need within your code.

Sub YourCode()
' Do your current code stuff here
If MsgBox("Do you want to accept this?",vbYesNo + vbQuestion) = vbYes
then
' Do the Yes code here
Else
' Do the No code here
End If
' continue with whatever other code you have.
End Sub
 
Fredg,

Southern at Heart needs Accept Decline and some other text on the Command
Button. I didn't think there was a way to get the message box to that, is
there?
 
only by creating your own, similar to what Gina mentioned.

The way I would do this is to create a custom message form
(frm_AcceptDecline). A small form with a simple message and your
Accept/Decline buttons. When either of these buttons is clicked, set the
forms Tag property, something like:

Private Sub cmd_Accept_Click

me.Tag = vbYes
me.visible = false

end sub
Private Sub cmd_Decline_Click

me.Tag = vbNo
me.visible = false

End sub

Then, I would create a function that opens the form and waits for it to be
hidden. Once it is hidden, then it retrieves the value from the Tag
property, closes the form, and passes the value back to the calling code

Public Function fnAcceptDecline

'opening this with acDialog set will pause all other
'activity until the form is closed or hidden
docmd.OpenForm "frm_AcceptDecline",,,,,acDialog
fnAcceptDecline = Form_frm_AcceptDecline.Tag
docmd.close acform, "frm_AcceptDecline"

End Function

Then, in your code, where you want to pause for input, you would just insert
a couple of lines of code:

if fnAcceptDecline = vbYes then
'Accept code here
else
'Decline code here
endif

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



Gina Whipp said:
Fredg,

Southern at Heart needs Accept Decline and some other text on the Command
Button. I didn't think there was a way to get the message box to that, is
there?
 
Fredg,

Southern at Heart needs Accept Decline and some other text on the Command
Button. I didn't think there was a way to get the message box to that, is
there?

Hi Gina,
I read the OP's message as wanting a generic "do you accept?" (which
would be answered by clicking "Yes" or "No") rather than specific
captions on buttons that read "accept" or "decline".

No, you cannot change the built in text of a Message Box button, but
the user can use an unbound form with whatever command button captions
he or she wishes. If that would be better suited, then a search of
www.groups.google.com would return many "how to's", or he can post
back and I'll dig a method out and reply. It's just a matter of
opening the form in acDialog which will stop code processing until the
form is made not visible or closed.
 
Fredg,

Okay, I thought so but one never knows... so I wanted to confirm that that
in fact could not be done with a message box.
 
fredg said:
Hi Gina,
I read the OP's message as wanting a generic "do you accept?" (which
would be answered by clicking "Yes" or "No") rather than specific
captions on buttons that read "accept" or "decline".

No, you cannot change the built in text of a Message Box button, but
the user can use an unbound form with whatever command button captions
he or she wishes. If that would be better suited, then a search of
www.groups.google.com would return many "how to's", or he can post
back and I'll dig a method out and reply. It's just a matter of
opening the form in acDialog which will stop code processing until the
form is made not visible or closed.

Actually, you can change the text of the Message Box.

See my May, 2005 "Access Answers" column in Pinnacle Publication's "Smart
Access". You can download the column (and sample database) for free at
http://www.accessmvp.com/DJSteele/SmartAccess.html

That having been said, I doubt I'd ever use that approach in a production
application.
 
Back
Top