Yes No box

G

Guest

I would like to have a message box appear and Ask "Would you like to add a
comment. No, Prints a report yes open another form so the person can add a
comment.
Thanks
chey
 
G

Guest

Hi Chey,

If msgbox("Would you like to add a comment?", vbQuestion+vbYesNo) = vbNo then
docmd.openreport "REPORTNAME"
else
docmd.openform "FORMNAME"
endif

hope that helps.

Damian.
 
G

Guest

Actually instead of opening the form I want to make a subform visable. How
do I do that?
 
S

Steve Schapel

Chey,

Try it like this...

If MsgBox("Add a comment?", vbQuestion+vbYesNo) = vbNo Then
DoCmd.OpenReport "YourReport"
Else
Me.NameOfSubform.Visible = True
End If
 
G

Guest

Okay another question to this. After playing with it I found some more
coding I will need to put it. Lets say. Yesterday I go in and say yes to
make a comment. Then today I go in and say no. When I say no I want it to
clear out the comment I made previous. Can I do that?

Thanks
Chey
 
S

Steve Schapel

Chey,

You mean on the same main form record? So we have this scenario...
You have a comment entered.
This comment is entered/accessed via a subform.
This subform is hidden unless you say Yes to the "add a comment" message
box.
Now you want that if you say No to the "add a comment" message box, any
previous message is deleted - but the previous message is still hidden
because the subform is still Visible=No.
Is this correct?
Well, it seems to me you will need to use an Update Query to remove the
comment. I guess one approach in code is something like this...

If MsgBox("Add a comment?", vbQuestion+vbYesNo) = vbNo Then
CurrentDb.Execute "UPDATE YourSubformTable SET Comment = Null
WHERE SubFormID=" & YourID
DoCmd.OpenReport "YourReport"
Else
Me.NameOfSubform.Visible = True
End If

I am pretty much shooting in the dark here because I don't know anything
about the tables behind your form and subform, and the relationship
between them.
 

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

Similar Threads

Question Box 2
Message Box 4
Sum 4
Update query?? 2
Question 8
Check box 2
Search records by unbound combo box - please help! 5
Taking data from one form and putting it in another 2

Top