Yes No message box

N

nancy

I have a check in system for participants for of a nonprofit organization.
The participants need to check in each time they come in and shop. When
signing in they choose their name from a combo box and the click the sign-in
button that runs to below event procedure. This works great. However some
time someone else will sign-in for the participant under the participants
name. I would like to modify the below event procedure that asks the
following questions.

Are you Sam ( the selected person). Yes or No.
If Yes then sign in Sam.
IF no. Are you shopping for Sam?
IF Yes. Please type in your name. (I will call this the Altperson)

Once the Altperson types in their name. I want the altperon name be added
to Sam’s ( or the selected perons) sign-in information.

Private Sub cmdSignIn_Click()
If IsNull(cboName) Then
MsgBox "Please select your name from the drop down list. Favor de
seleccionar su nombre de la lista siguiente"
ElseIf DCount("ShopID", "Shoplog", "volID=" & cboName & " And
ShopDate=Date()") = 0 Then
DoCmd.RunSQL "Insert Into Shoplog (volID, ShopDate, SHOPSignin) Values("
& cboName & ",Date(),Time());"
MsgBox cboName.Column(1) & ", you have signed in successfully!"
cboName = Null
DoCmd.Close

Else
MsgBox cboName.Column(1) & ", you have already signed in today! Ya se
ha registrado por el dia de hoy."

End If
 
D

David H

The MsgBox can be used as a function which returns a result as in

result = MsgBox(...)
If result = vbYes then
end if

If result = vbNo then
end if

However, I would suggest going with an approach that eliminates or reduces
the ability of the person to sign in as somebody else. I would probably go
with a form whereby the user enters their phone number (or other unique
identifier) to select their information then clicks 'Sign-In' to actually
sign in. Anytime you're presenting a person with a list of options there's
always the possibility that they may not select the right one either
intentionally or by accident.
 
N

nancy

Thanks for the info. I will pass it on.

I typed in the message box information however I get a Comple error:
Variable not Defined. What am I missing?
 
J

JimS

Well, if you have option explicit set, you need to dim "result" as a variant
You also need to be sure you use the Msgbox options correctly. You didn't
show that code. I suspect a typo in that.
 
M

Matt Williamson

nancy said:
Thanks for the info. I will pass it on.

I typed in the message box information however I get a Comple error:
Variable not Defined. What am I missing?

If you have Option Explicit set, you need to dimension result

Dim result as long

result = MsgBox(...)
select case result
case vbYes
'do stuff
case vbNo
'do other stuff
case Else
'do stuff if result isn't Yes or No
end select

HTH

Matt
 
N

nancy

Thanks I got it to work.

Now I am working the second part of the program.

If the person filling in as an alternate person. I would like to have it
prompt the person to type in his name. How can I do this.


ElseIf result = vbNo Then
Result1 = MsgBox("Are you signing in for " & cboName.Column(1) & "",
vbYesNoCancel)
If Result1 = vbYes Then
If DCount("ShopID", "Shoplog", "volID=" & cboName & " And
ShopDate=Date()") = 0 Then

***This is where I want it to promt the person to type in his name. and the
insert in the the talble the, date, altname, volID.***

Else: MsgBox cboName.Column(1) & ", you have already signed in
today! Ya se ha registrado por el dia de hoy."

End If
ElseIf Result1 = vbNo Then
DoCmd.Close
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top