Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error Handling | Excel Programming | |||
Error Handling | Excel Programming | |||
Error handling with a handling routine | Excel Programming | |||
error handling | Excel Programming | |||
Error Handling | Excel Programming |