Hey all
I am trying to print a record that I have just inserted on my form. My code:
It prints all the records in the table when I would like to print the record I have just inserted.
Any pointers will be highly appreciated.
Many thanks,
Rupa
I am trying to print a record that I have just inserted on my form. My code:
Code:
[SIZE=3][FONT=Times New Roman]Private Sub PrintTempSlip_Click()[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]On Error GoTo Err_PrintTempSlip_Click[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]If (IsNull(StNo.Value) = True) And (IsNull(Forename.Value) = True) And (IsNull(Surname.Value) = True) Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]MsgBox ("Please enter your Number, Forename and Surname")[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]ElseIf (IsNull(Forename.Value) = True) And (IsNull(Surname.Value) = True) Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]MsgBox ("Please enter your Forename and Surname")[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]ElseIf (IsNull(StNo.Value) = True) And (IsNull(Forename.Value) = True) Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]MsgBox ("Please enter your Number and Forename")[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]ElseIf (IsNull(StNo.Value) = True) And (IsNull(Surname.Value) = True) Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]MsgBox ("Please enter your Number and Surname")[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]ElseIf (IsNull(StNo.Value) = True) Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]MsgBox ("Please enter your Number")[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]ElseIf (IsNull(Forename.Value) = True) Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]MsgBox ("Please enter your Forename")[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]ElseIf (IsNull(Surname.Value) = True) Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]MsgBox ("Please enter your Surname")[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]Else[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]DoCmd.RunCommand acCmdSaveRecord[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]Dim stDocName As String[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]stDocName = "Temporary Slip"[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]DoCmd.OpenReport stDocName, acNormal[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]MsgBox ("Please collect your temporary slip from a member of staff")[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]DoCmd.GoToRecord , , acNewRec[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]End If[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]Exit_PrintTempSlip_Click:[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Exit Sub[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]Err_PrintTempSlip_Click:[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] MsgBox Err.Description[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Resume Exit_PrintTempSlip_Click[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] [/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]End Sub[/SIZE][/FONT]
It prints all the records in the table when I would like to print the record I have just inserted.
Any pointers will be highly appreciated.
Many thanks,
Rupa