G
Guest
I have a table HYInReg in which the field "RegisterNumber" is set as Text and
is required and uses the following code:-
Private Sub RegisterNumber_Click()
If Me.NewRecord Then
Dim strWhere As String
Dim varResult As Variant
strWhere = "RegisterNumber Like """ & Format(Date, "yy") & "*"""
varResult = DMax("RegisterNumber", "HYInReg", strWhere)
If IsNull(varResult) Then
Me.RegisterNumber = Format(Date, "yy") & "-000001"
Else
Me.RegisterNumber = Left(varResult, 3) & _
Format(Val(Right(varResult, 4)) + 1, "000000")
End If
End If
End Sub
On my form "RegEntryForm" which is used for data entry (add only) I have a
print button which uses the following code:-
Private Sub cmdPrint_Click()
Dim StrDocName As String
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[RegisterNumber]=""" & Me.[RegisterNumber] & """"
DoCmd.OpenReport "RegEntryFormRpt", acViewPreview, , strWhere
End If
End Sub
If the button is selected without the Register Number field being populated
then the following RUN TIME ERROR 3314 message appears. If I end this and
populate the field then select the print button all is works. However
instead of the error message I would like a reminder (messagebox) to appear
reminding the user to click on the RegisterNumber field which then gives you
the Register Number. Any help to this very green novice would be greatly
appreciated.
is required and uses the following code:-
Private Sub RegisterNumber_Click()
If Me.NewRecord Then
Dim strWhere As String
Dim varResult As Variant
strWhere = "RegisterNumber Like """ & Format(Date, "yy") & "*"""
varResult = DMax("RegisterNumber", "HYInReg", strWhere)
If IsNull(varResult) Then
Me.RegisterNumber = Format(Date, "yy") & "-000001"
Else
Me.RegisterNumber = Left(varResult, 3) & _
Format(Val(Right(varResult, 4)) + 1, "000000")
End If
End If
End Sub
On my form "RegEntryForm" which is used for data entry (add only) I have a
print button which uses the following code:-
Private Sub cmdPrint_Click()
Dim StrDocName As String
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[RegisterNumber]=""" & Me.[RegisterNumber] & """"
DoCmd.OpenReport "RegEntryFormRpt", acViewPreview, , strWhere
End If
End Sub
If the button is selected without the Register Number field being populated
then the following RUN TIME ERROR 3314 message appears. If I end this and
populate the field then select the print button all is works. However
instead of the error message I would like a reminder (messagebox) to appear
reminding the user to click on the RegisterNumber field which then gives you
the Register Number. Any help to this very green novice would be greatly
appreciated.