bleakhouse
New member
- Local time
- Today, 05:35
- Joined
- Mar 7, 2019
- Messages
- 14
I thought that this would be simple but!
I have a field in a table defined as an attachment, in the field i have attached an image of a barcode.
All i want to do is retreive the picture from the table and print it on a label.
All my code to select the record works, but when I try to retreive the record I get the following error.
Object variable with block variable not set, I must be missing something or not coding correctly.
My code is listed below.
Private Sub PrLabels_Click()
Dim Counter1 As Integer
Dim PlantProductcode As String
Dim PlantName As String
Dim PlantDescription As String
Dim PlantOptions As String
Dim Response As Integer
Dim PlantPrice As Currency
Dim CResponse As String
Dim SearchFor As String
Dim Barcode As String
Dim Barcode2 As Attachment
Dim LabelOutput As String
Dim Recsetop As Recordset
' CResponse = InputBox("Enter (a)ll Labels or (I)ndividual Label")
Set Recsetop = CurrentDb.OpenRecordset("extracted_LabeltoPrint")
CurrentDb.Execute ("Delete * from extracted_LabeltoPrint")
LabelOutput = Environ("userprofile") & "\desktop\HedgerowLabelsToPrint\Hedgerow_Labels.pdf"
PlantProductcode = Me.dataDisplaySubform("code")
PlantDescription = Me.dataDisplaySubform("name")
PlantOptions = Me.dataDisplaySubform("options")
PlantPrice = Me.dataDisplaySubform("price")
Barcode = Me.dataDisplaySubform("barcode")
Barcode2 = Me.dataDisplaySubform("barcode2") - error comes here
Stop
Recsetop.AddNew
Recsetop!code = PlantProductcode
Recsetop!Name = PlantDescription
Recsetop!Options = PlantOptions
Recsetop!Price = PlantPrice
Recsetop!Barcode = Barcode
recetop!Barcode2 = Barcode2
Recsetop.Update
Recsetop.MoveFirst
PlantProductcode = Recsetop("code")
PlantDescription = Recsetop("name")
PlantOptions = Recsetop("options")
PlantPrice = Recsetop("price")
Barcode = Recsetop("barcode")
Barcode2 = Recsetop("barcode2")
Report1Output = Environ("userprofile") & "\desktop\HedgerowLabelsToPrint\HedgerowLabels.pdf" 'Booklet Header
DoCmd.OutputTo acOutputReport, "Print Labels2_Test", acFormatPDF, Environ("userprofile") & "\desktop\HedgerowLabelsToPrint\HedgerowLabels.pdf "
Application.FollowHyperlink Environ("userprofile") & "\desktop\HedgerowLabelsToPrint\Hedgerowlabels.pdf"
end sub
Any help or pointers would be much appreciated
Thanks in anticipation
Regards
Ian Clegg
I have a field in a table defined as an attachment, in the field i have attached an image of a barcode.
All i want to do is retreive the picture from the table and print it on a label.
All my code to select the record works, but when I try to retreive the record I get the following error.
Object variable with block variable not set, I must be missing something or not coding correctly.
My code is listed below.
Private Sub PrLabels_Click()
Dim Counter1 As Integer
Dim PlantProductcode As String
Dim PlantName As String
Dim PlantDescription As String
Dim PlantOptions As String
Dim Response As Integer
Dim PlantPrice As Currency
Dim CResponse As String
Dim SearchFor As String
Dim Barcode As String
Dim Barcode2 As Attachment
Dim LabelOutput As String
Dim Recsetop As Recordset
' CResponse = InputBox("Enter (a)ll Labels or (I)ndividual Label")
Set Recsetop = CurrentDb.OpenRecordset("extracted_LabeltoPrint")
CurrentDb.Execute ("Delete * from extracted_LabeltoPrint")
LabelOutput = Environ("userprofile") & "\desktop\HedgerowLabelsToPrint\Hedgerow_Labels.pdf"
PlantProductcode = Me.dataDisplaySubform("code")
PlantDescription = Me.dataDisplaySubform("name")
PlantOptions = Me.dataDisplaySubform("options")
PlantPrice = Me.dataDisplaySubform("price")
Barcode = Me.dataDisplaySubform("barcode")
Barcode2 = Me.dataDisplaySubform("barcode2") - error comes here
Stop
Recsetop.AddNew
Recsetop!code = PlantProductcode
Recsetop!Name = PlantDescription
Recsetop!Options = PlantOptions
Recsetop!Price = PlantPrice
Recsetop!Barcode = Barcode
recetop!Barcode2 = Barcode2
Recsetop.Update
Recsetop.MoveFirst
PlantProductcode = Recsetop("code")
PlantDescription = Recsetop("name")
PlantOptions = Recsetop("options")
PlantPrice = Recsetop("price")
Barcode = Recsetop("barcode")
Barcode2 = Recsetop("barcode2")
Report1Output = Environ("userprofile") & "\desktop\HedgerowLabelsToPrint\HedgerowLabels.pdf" 'Booklet Header
DoCmd.OutputTo acOutputReport, "Print Labels2_Test", acFormatPDF, Environ("userprofile") & "\desktop\HedgerowLabelsToPrint\HedgerowLabels.pdf "
Application.FollowHyperlink Environ("userprofile") & "\desktop\HedgerowLabelsToPrint\Hedgerowlabels.pdf"
end sub
Any help or pointers would be much appreciated
Thanks in anticipation
Regards
Ian Clegg