Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Error Checking


Reply
 
Thread Tools Display Modes
  #1  
Old 11-25-2003, 05:57 AM
scantor145 scantor145 is offline
Centurion
 
Join Date: Oct 2003
Posts: 196
Question Error Checking


Below is a portion of a macro that is to check to see if a value was entered into a text box called txtCalConc. If no value was entered then I have a warning message screen pop up. I then reset the focus on the text box.

Problem: The message appears with no trouble, however, when I the select OK button, although I saw that focus was set on the textbox, the form disappeared immediately and the macro proceeded as normal.

What statement do I need after

Code:
frmOptions.txtCalConc.SetFocus

to go back to the form and enter an appropriate value?



Code:
Private Sub cmdContinue_Click() Dim Press As Single If frmOptions.chkCal = True And frmOptions.txtCalConc = "" Then Press = MsgBox("Enter a concentration for the Calibrator", vbCritical) frmOptions.txtCalConc.SetFocus End If frmOptions.Hide Call NewWork End Sub
Reply With Quote
  #2  
Old 11-25-2003, 06:30 AM
Insomniac Insomniac is offline
Contributor

* Expert *
 
Join Date: Mar 2003
Location: Adelaide,Australia
Posts: 681
Default

Only had a quick look, but I think you want something like this:
Code:
Private Sub cmdContinue_Click() Dim Press As Single If frmOptions.chkCal = True And frmOptions.txtCalConc = "" Then Press = MsgBox("Enter a concentration for the Calibrator", vbCritical) frmOptions.txtCalConc.SetFocus Else frmOptions.Hide Call NewWork End If End Sub
Reply With Quote
  #3  
Old 11-25-2003, 08:18 AM
mark007's Avatar
mark007 mark007 is offline
Licensed to post

* Expert *
 
Join Date: Jul 2003
Location: York, Uk
Posts: 1,637
Default

or

Code:
Private Sub cmdContinue_Click() Dim Press As Single If frmOptions.chkCal = True And frmOptions.txtCalConc = "" Then Press = MsgBox("Enter a concentration for the Calibrator", vbCritical) frmOptions.txtCalConc.SetFocus Exit sub End If frmOptions.Hide Call NewWork End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->