Wait for user response before doing anything.

Reply

Join Date: Jan 2005
Posts: 6
Reputation: amarsha4 is an unknown quantity at this point 
Solved Threads: 0
amarsha4 amarsha4 is offline Offline
Newbie Poster

Wait for user response before doing anything.

 
0
  #1
Jan 27th, 2009
Hi,

Apologies if I'm missing something really easy here:

I have a TabStrip with 4 tabs on my form. When the user is editing the information on one of the tabs I want to display a message box confirming whether the data should be saved. Here is what I have:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub tabMainForm_Click(PreviousTab As Integer)
  2. If editing Then
  3. If MsgBox("Save changes?", vbYesNoCancel, applicationTitle) = vbYes Then
  4. cmdSave_Click (tabMainForm.Tab)
  5. End If
  6. End If
  7. If tabMainForm.Tab = 1 Then
  8. staffRst.Fields("BI") = CalculateBI
  9. staffRst.Update
  10. txtBI.Text = staffRst.Fields("BI")
  11. End If
  12. End Sub

The program will switch to the new tab before displaying the message. Is there any way I can show the message box first then decide whether to switch tabs?

Thanks in advance,

Andy.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Wait for user response before doing anything.

 
0
  #2
Jan 27th, 2009
can you put the code on the tab's mousedown event?
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 42
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: Wait for user response before doing anything.

 
0
  #3
Jan 27th, 2009
Try the change event, if there's an cancel property on their parameter then use it. or maybe the mousedown event.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: Wait for user response before doing anything.

 
0
  #4
Jan 27th, 2009
I have a TabStrip with 4 tabs on my form. When the user is editing the information on one of the tabs I want to display a message box confirming whether the data should be saved.
Hi, You have to display a message box, when closing a form or changing one tab to another.

If Changing from one tab to another,
set editing flag on All the controls change event (Current Tab) and clear it after the confirmation. Suppose Text1 is in First Tab, then

  1. Dim bEditing As Boolean
  2.  
  3. Private Sub tabMainForm_Click(PreviousTab As Integer)
  4. If bEditing Then
  5. Select Case MsgBox("Save changes?", vbYesNoCancel, applicationTitle) = vbYes
  6. Case vbYes
  7. cmdSave_Click (tabMainForm.Tab)
  8. Case vbNo
  9.  
  10. Case vbCancel
  11. Exit Sub
  12. End Select
  13. End If
  14. 'ClearFlag
  15. bEditing = False
  16. End Sub
  17.  
  18. Private Sub Text1_Change()
  19. bEditing = True
  20. End Sub
Last edited by selvaganapathy; Jan 27th, 2009 at 11:11 pm.
KSG
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 6
Reputation: amarsha4 is an unknown quantity at this point 
Solved Threads: 0
amarsha4 amarsha4 is offline Offline
Newbie Poster

Re: Wait for user response before doing anything.

 
0
  #5
Feb 11th, 2009
Thank you both for your replies, the MouseDown event worked fine, but I now have the same problem with a ListBox.

The names of items are listed in a ListBox, when an item is selected its details are filled into several TextBoxes underneath the list.

Basically I need the same kind of thing; if the user tries to select a different list item while editing = True then I want to display the message and perform no action. The MouseDown event is firing but the ListIndex is still changing.

Any ideas? I know I could set the ListBox.Enabled = False but I would rather use a simpler solution as before.

Hope someone can help,

Andy
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC