Prev: ESTOU SEM TELEFONE
Next: não acho meu orkut
From: Richard on 13 Jan 2010 17:04 Hi all, I use the below code to print Dymo labels, the purpose is to print the number of labels in the textbox TotalParcels.The code works fine on exsting records. When I attempt to print a new record I get Run-Time Error '94' Invalid use of Null The code highlights on this line >> For L = 1 To Forms!frmScan!ScanSub.Form.Parcels When I hover the mouse over the L it = 0 Thank you Richard ------------------------------------------------------------------------------------------------ Private Sub Label5_Click() Dim strWhere As String Dim L As Long If Me.Dirty Then Me.Dirty = False End If If Me.NewRecord Then MsgBox "Select a record to print" Else strWhere = "[ScanID] = " & Me.[ScanID] End If For L = 1 To Forms!frmScan!ScanSub.Form.Parcels DoCmd.OpenReport "rptScanlogDymo", acViewNormal, , strWhere Next L DoCmd.GoToRecord , , acNewRec Department.SetFocus End Sub
From: John W. Vinson on 13 Jan 2010 17:51 On Wed, 13 Jan 2010 14:04:01 -0800, Richard <Richard(a)discussions.microsoft.com> wrote: >Hi all, > >I use the below code to print Dymo labels, the purpose is to print the >number of labels in the textbox TotalParcels.The code works fine on exsting >records. When I attempt to print a new record I get Run-Time Error '94' >Invalid use of Null The code highlights on this line >> For L = 1 To >Forms!frmScan!ScanSub.Form.Parcels You'll need to save the current record to disk: If Me.Dirty Then Me.Dirty = False will do it, before you'll be able to loop through the records. -- John W. Vinson [MVP]
From: Richard on 13 Jan 2010 19:37 "John W. Vinson" wrote: > You'll need to save the current record to disk: > > If Me.Dirty Then Me.Dirty = False > > will do it, before you'll be able to loop through the records. > -- > > John W. Vinson [MVP] Thanks John for the reply. I am still unsure on the direction I need to go. I thought the me.dirty=false line saved the record? And if there is a value in the Parcels textbox I shouldn't get an error. Richard
From: John W. Vinson on 13 Jan 2010 19:43 On Wed, 13 Jan 2010 14:04:01 -0800, Richard <Richard(a)discussions.microsoft.com> wrote: >Hi all, > >I use the below code to print Dymo labels, the purpose is to print the >number of labels in the textbox TotalParcels.The code works fine on exsting >records. When I attempt to print a new record I get Run-Time Error '94' >Invalid use of Null The code highlights on this line >> For L = 1 To >Forms!frmScan!ScanSub.Form.Parcels > >When I hover the mouse over the L it = 0 >Thank you >Richard >------------------------------------------------------------------------------------------------ >Private Sub Label5_Click() >Dim strWhere As String >Dim L As Long > > If Me.Dirty Then > Me.Dirty = False > End If > > > If Me.NewRecord Then > MsgBox "Select a record to print" > Else > strWhere = "[ScanID] = " & Me.[ScanID] > End If > > > For L = 1 To Forms!frmScan!ScanSub.Form.Parcels > DoCmd.OpenReport "rptScanlogDymo", acViewNormal, , strWhere > Next L > > > DoCmd.GoToRecord , , acNewRec > Department.SetFocus > >End Sub Hrm. Apologies for the hasty answer previously! What's in Forms!frmScan!ScanSub.Form.Parcels? Is the subform open and populated? You'll get this error if that control is NULL or does not exist. -- John W. Vinson [MVP]
From: Richard on 13 Jan 2010 20:30
> Hrm. Apologies for the hasty answer previously! > > What's in Forms!frmScan!ScanSub.Form.Parcels? Is the subform open and > populated? You'll get this error if that control is NULL or does not exist. > -- > > John W. Vinson [MVP] > . Yes the subform is open and parcels is populated with a number Richard > |