Message box inception (1 Viewer)

Coolzie1

Registered User.
Local time
Today, 23:36
Joined
May 13, 2017
Messages
11
Hi all,

I am working on a form where you will search for results held in a table and the form is going to run a continuous set of results if any are found. I have attempted to set up a series of message box's in the event that nothing is found as this would mean a few different things. However when trying to run the VBA from the records set bringing nothing back the code seems to want to run through the whole thing whether the answer is yes or no and it doesn't pick up that if you have selected yes to continue down path A and if you select no then you miss path A and go to path B etc. The issue I need to resolve is that there will be 3/r tiers of questions so you may select Yes, Yes, No and then it kicks you out with a pop up of what you will need to do, kind of like how a flow chart works but within pop up box's.

My main question is, is it possible? And if so how do I get it to stop continuing through the whole code and notice that if you clicked No on the first question it shouldn't bring you to the first vbNo if statement as this is in the event the first pop up was answered yes and then the user clicks no?

Thank you in advance for any help and advice given :)
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:36
Joined
Feb 19, 2013
Messages
16,642
can't provide much help without knowing what your code is.

Go to the advanced editor, copay and paste your code in and surround with the code tags (highlight your code and click on the # button). If you don't use the code tags your code will be very difficult to read and most people won't bother trying to help
 

Coolzie1

Registered User.
Local time
Today, 23:36
Joined
May 13, 2017
Messages
11
Hi,

Unfortunately as it is for a work database and I am not at work or able to provide the full exact code for data protection reasons I cannot give a full overview however a rough example of what I am trying to do would be something like...

If recordset = 0 then
Msg = "no results found, is the search criteria correct?"
Style = vbQuestion, vbYesNo
Title = "no results found"
MsgBox = (msg, style, title)
'this then leads on to the vbYesNo for the agent having selected yes on the original pop up box
If vbYes then
Msg = "Has the required data been released since the last update?"
Style = vbQuestion, vbYesNo
Title = "further question"
MsgBox = (msg, style, title)
'this then leads on to the vbOKOnly for the agent having selected yes on the second pop up box if the agent selects yes both times
If vbYes then
Msg = "please speak to management to request a data table update"
Style = vbInformation, vbOKOnly
Title = "Update Required"
MsgBox = (msg, style, title)
'this then leads on for the agent having selected No on the Second message box for the question of whether the data has been updated
ElseIf vbNo then
Msg = "This means the data searched for is not supported for replacement, please advise the customer of this"
Style = vbInformation, vbOKOnly
Title = "Item not supported"
MsgBox = (msg, style, title)
'this then leads on to the vbOKOnly for the agent having selected No on the original pop up box
ElseIf vbNo then
Msg = "Please search using the correct search criteria"
Style = vbQuestion, vbOKOnly
Title = "Search needs to be redone"
MsgBox = (msg, style, title)
End if
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:36
Joined
Feb 19, 2013
Messages
16,642
with respect a) the code is unreadable due to lack of code tags (you were asked) and b) being 'aircode' how are we supposed to determine what the problem is?

but to give the first few rows a go

1. If recordset = 0 then.... a recordset cannot =0


2. this is not syntactically correct

Style = vbQuestion, vbYesNo


3. this
MsgBox = (msg, style, title)
'this then leads on to the vbYesNo for the agent having selected yes on the original pop up box
If vbYes then

needs to be

if MsgBox = (msg, style, title)=vbyes then
'this then leads on to the vbYesNo for the agent having selected yes on the original pop up box
 

Coolzie1

Registered User.
Local time
Today, 23:36
Joined
May 13, 2017
Messages
11
My apologies as stated above the code is all at my workplace so I am not able to access it.

I am also doing this whole thread off of my phone so it is a little harder to do it all as I have had to type out all of the above with the memory of what my code looked like and improvise.

I do have in the code the if statement of the recordset = 0 however I think it is Me.Recordset = 0 come to think of it and it has worked to bring up the MsgBox.

The main question I need to know is can it be done where you have multiple tiers of questions without the message box code going through each one after another. I would need it to differentiate between the yes no options on each level rather than one after another, if not then I guess I will just have to string a pop up box form together depending on the outcomes of buttons being pressed dictates which string would be shown to the user?

Thank you for the above quote of how the message box would work but I don't quite understand how this is any different to my if statements as it would just keep reading every MsgBox code one after another would it not?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:36
Joined
Feb 19, 2013
Messages
16,642
sorry, left an = sign in

if MsgBox (msg, style, title)=vbyes then


I don't understand what you mean by this
can it be done where you have multiple tiers of questions without the message box code going through each one after another
but if I've understood correctly you would use nested if's

Code:
if this then
    do something
else
    if something else then
        do something else
    else
       if ...
       else
          if...
          end if
       end if
    end if
end if
 

Users who are viewing this thread

Top Bottom