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 below 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 to 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.

My code is below if necessary. Any input would be greatfully appreciated.

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Do Until issave = True
Dim theBk As Workbook
fto = "Z:\Systemdown\" & CommandN & "\Notes.xls"
Set theBk = Workbooks.Open(FileName:=fto, Password:="thunder",
WriteResPassword:="thunder")
If theBk.ReadOnly Then
theBk.Close False
issave = False
Else
newrow =
Workbooks("Notes.xls").Sheets("data").Range("A6553 6").End(xlUp).Row + 1
Workbooks("Notes.xls").Sheets("data").Cells(newrow , 1).Value =
Environ("UserName")
Workbooks("Notes.xls").Sheets("data").Cells(newrow , 2).Value = Now
Workbooks("Notes.xls").Sheets("data").Cells(newrow , 3).Value = namex
Workbooks("Notes.xls").Sheets("data").Cells(newrow , 4).Value = team
Workbooks("Notes.xls").Sheets("data").Cells(newrow , 5).Value =
TextBox1.Value
Workbooks("Notes.xls").Sheets("data").Cells(newrow , 6).Value =
TextBox2.Value

With Workbooks("Notes.xls").Sheets("data").Cells(newrow , 7)
.Value = CDate(TextBox3.Text)
.NumberFormat = "dd-mm-yyyy"
End With

Workbooks("Notes.xls").Sheets("data").Cells(newrow , 8).Value =
TextBox4.Value
Workbooks("Notes.xls").Sheets("data").Cells(newrow , 9).Value =
TextBox5.Text
Workbooks("Notes.xls").Sheets("data").Cells(newrow , 10).Value =
TextBox6.Value


theBk.Close True
Application.ScreenUpdating = True
MsgBox "Records Saved"
Application.ScreenUpdating = False

issave = True

End If
Loop
Application.ScreenUpdating = False
Unload Wrapform
End Sub
--
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 Kevin Excel Discussion (Misc queries) 4 June 19th 08 12:31 AM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
Error handling John Pierce Excel Programming 3 October 3rd 03 12:17 PM
Error Handling Rob Bovey Excel Programming 0 August 7th 03 12:11 AM
Error Handling Bill Lunney Excel Programming 0 August 6th 03 11:56 PM


All times are GMT +1. The time now is 10:50 PM.

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"