Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Error handling.

I would like some general advice on error handling please.

In my code once a user has filed out some values on a form the system
tests for a multiuser workbook being open. Only when it gets the book as read
write will it update the workbook then save it.

Could you give me some advice on where to go with the problem of errors
ocuring in the update. e.g. if the user leaves a the date textbox blank or
types text then a error 13 mismatch occurs and the program stops with the
multiuser workbook open.

I would like to avoid this for two reasons.
1. as its password protected i dont want the users in it.Just the form to
update it.
2. if it crashes and a user leaves it open then it will prevent other users
being able to update the data.

any advice on how to make sure everything completes between opening and
closeing the workbook would help.
--
Regards and Thanks for any assistance.

Francis Brown.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Error handling.

One way would be to check the value in the textbox before you proceed to
opening the file etc. If it is not a valid date stop processing:

Private Sub CommandButton1_Click()
Dim tDate As Variant

On Error Resume Next
tDate = DateValue(Me.TextBox1.Text)
On Error GoTo 0

If Not tDate = Empty Then
'Open file and process form data
Else
MsgBox "Enter a DATE please"
End If
Unload Me
End Sub

Hope this helps
Rowan

Francis Brown wrote:
I would like some general advice on error handling please.

In my code once a user has filed out some values on a form the system
tests for a multiuser workbook being open. Only when it gets the book as read
write will it update the workbook then save it.

Could you give me some advice on where to go with the problem of errors
ocuring in the update. e.g. if the user leaves a the date textbox blank or
types text then a error 13 mismatch occurs and the program stops with the
multiuser workbook open.

I would like to avoid this for two reasons.
1. as its password protected i dont want the users in it.Just the form to
update it.
2. if it crashes and a user leaves it open then it will prevent other users
being able to update the data.

any advice on how to make sure everything completes between opening and
closeing the workbook would help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Error handling.

Francis,

Test the values in the userform.

You can test the textbox date with something like

fError = False
With Textbox4
If .Text < "" Then
If IsDate(.Text) Then
fError = True
End If
End If

If fError Then
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
End With

You could add that code to the OK/submit button.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Francis Brown" wrote in message
...
I would like some general advice on error handling please.

In my code once a user has filed out some values on a form the system
tests for a multiuser workbook being open. Only when it gets the book as

read
write will it update the workbook then save it.

Could you give me some advice on where to go with the problem of errors
ocuring in the update. e.g. if the user leaves a the date textbox blank or
types text then a error 13 mismatch occurs and the program stops with the
multiuser workbook open.

I would like to avoid this for two reasons.
1. as its password protected i dont want the users in it.Just the form to
update it.
2. if it crashes and a user leaves it open then it will prevent other

users
being able to update the data.

any advice on how to make sure everything completes between opening and
closeing the workbook would help.
--
Regards and Thanks for any assistance.

Francis Brown.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Error handling.

Seeing as how the IsDate will fail if no entry is there, we could just use
the IsDate ..

If IsDate(TextBox4.Value) Then
'your code here..
End If

HTH

--
Regards,
Zack Barresse, aka firefytr, (GT = TFS FF Zack)
To email, remove the NO SPAM. Please keep correspondence to the board, as
to benefit others.


"Bob Phillips" wrote in message
...
Francis,

Test the values in the userform.

You can test the textbox date with something like

fError = False
With Textbox4
If .Text < "" Then
If IsDate(.Text) Then
fError = True
End If
End If

If fError Then
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
End With

You could add that code to the OK/submit button.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Francis Brown" wrote in message
...
I would like some general advice on error handling please.

In my code once a user has filed out some values on a form the system
tests for a multiuser workbook being open. Only when it gets the book as

read
write will it update the workbook then save it.

Could you give me some advice on where to go with the problem of errors
ocuring in the update. e.g. if the user leaves a the date textbox blank
or
types text then a error 13 mismatch occurs and the program stops with the
multiuser workbook open.

I would like to avoid this for two reasons.
1. as its password protected i dont want the users in it.Just the form to
update it.
2. if it crashes and a user leaves it open then it will prevent other

users
being able to update the data.

any advice on how to make sure everything completes between opening and
closeing the workbook would help.
--
Regards and Thanks for any assistance.

Francis Brown.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Handling Don Rouse Excel Programming 1 August 2nd 05 06:02 PM
Error Handling Billy Boone Excel Programming 1 July 1st 05 02:21 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
error handling jeffP Excel Programming 1 July 3rd 04 06:10 PM
Error Handling James Agostinho Excel Programming 1 January 30th 04 06:40 AM


All times are GMT +1. The time now is 06:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"