LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
dbl dbl is offline
external usenet poster
 
Posts: 2
Default Blocking Error 3021 No current record

Hi I have a form with a field called "Field137" if this field is left blank
for any reason when trying to print out certain reports using the following
code:


Private Sub Command258_Click()
On Error GoTo Err_Button258_Click

If Me.Field137 = "" Then
MsgBox "You have not entered Bodyshop To Be Assigned or a Bodyshop Name"
End If
Dim LinkCriteria As String
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20
LinkCriteria = "[Field143]"

Docname = "ClaimForm"
DoCmd.OpenReport Docname, acPreview
Docname = "ClaimFormLetterFaxRpt"
DoCmd.OpenReport Docname, acPreview

Exit_Button258_Click:
Exit Sub

Err_Button258_Click:
MsgBox Error$
Resume Exit_Button258_Click
Exit Sub
End Sub

If field137 is left blank for any reason then up pops the error box giving
the following message "ERROR 3021 No current record", when you go into debug
it highlights the following function

Function LiscYrs(varTestDate As Variant) As Variant
Dim varYrs As Variant

If IsNull(varTestDate) Then
varYrs = Null
Else
varYrs = DateDiff("yyyy", varTestDate, Date)
(THIS IS THE LINE HIGHLIGHTED IN YELLOW)

If Date < DateSerial(Year(Date), Month(varTestDate), _
Day(varTestDate)) Then
varYrs = varYrs - 1
End If
End If
LiscYrs = varYrs

End Function


How do I get the code to print this error msg MsgBox "You have not entered
Bodyshop To Be Assigned or a Bodyshop Name"
and not jump into any code I would like it to set the focus on Field137 if
possible when the operator clicks the ok button.

Any help would be appreciated.

Bob


 
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
Excel 2007 Error message when trying to record Macro Beth Excel Worksheet Functions 1 May 16th 10 08:32 AM
How can I add the new record from another list to current one? PattyS Excel Worksheet Functions 1 January 10th 10 03:56 PM
Excel 2007 error 'xx.xls cannot be saved in the current format' NK Excel Discussion (Misc queries) 0 May 21st 09 12:49 PM
On Error, Capturing current module and actual line of code Paul Martin Excel Programming 4 June 13th 04 06:21 AM
Current row/record shown when opening data/form buczacz Excel Programming 8 October 22nd 03 04:31 AM


All times are GMT +1. The time now is 02:19 AM.

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

About Us

"It's about Microsoft Excel"