Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blank Error Message 1

Status
Not open for further replies.

MarkWaddington

Programmer
Aug 19, 2002
64
0
0
GB
Hi, something has gone wrong with my main form in my database. When I open the form I get a blank error message, if I try to catch the error number, it tells me the error number is "0".

I can't see anything wrong with my code, the only way i can stop the message box from appearing is by taking out all my error handling code - but I don't really want to do that.

Has anybody got any clues as to what I can do to determine the source of the error?

Here's the code that is attached to my form's "on load" event handler - strangely enough even if I remove all this I still get the error, but this is the only code that runs when I open the form so go figure!

Any help greatly appreciated.

Private Sub Form_Load()

On Error GoTo ErrorHandler

If ((RegNo) > 0) Then

Dim db As Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("LockedRecords", dbOpenDynaset)

If (rs.RecordCount) = 0 Then

With rs
.AddNew
.Fields("StaffName") = CurrentUser()
.Fields("LockedRecord") = RegNo
.Update
End With

Else

With rs
.MoveFirst
Do While Not .EOF
If .Fields("LockedRecord") = (RegNo) Then
MsgBox "This record has been locked by user " + .Fields("StaffName") + ". This is most probably because they are viewing the record right now. Please try again later, or inform the member of staff in question that you wish to view this record."
DoCmd.Close
Exit Sub
End If
.MoveNext
Loop
End With

With rs
.AddNew
.Fields("StaffName") = CurrentUser()
.Fields("LockedRecord") = RegNo
.Update
End With

Set rs = Nothing
Set db = Nothing

End If
End If

If (Forms!Client!Gender = "Female") Then
Forms!Client.Section(0).BackColor = 14135039

End If
If (Forms!Client!Gender = "Male") Then
Forms!Client.Section(0).BackColor = "16562343"

End If
If (Forms!Client!Gender = "Not Known") Then
Forms!Client.Section(0).BackColor = 10079487

End If

With CodeContextObject
If (.Disability = 0) Then
Forms!Client!DisabilityDetails.Visible = False
End If
If (.Disability = -1) Then
Forms!Client!DisabilityDetails.Visible = True
End If
End With

ErrorHandler:

MsgBox Err.Description

If (Err.Number = 2427) Then

MsgBox "You are a read only user, if you feel you should have higher access privileges, please contact the IT Administrator", vbInformation

End If

End Sub
 
Hi Mark

Glad you figured it out; just 1 remark:
there's no
Code:
Exit Sub
before your ErrorHandler starts - so the ErrorHandler code will always run even if there's no error - hence the blank msgbox

Cheers
(& enjoy xmas)

Nikki ;-)
 
Yeah I realised that after I had posted the message! Doh!

Thanks for replying :)
 
Nikita6003,

You get a star for the Exit Sub post. I was pulling my hair out over a blank error message.

ARFFMarine

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top