Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

object-defined error - confused because it's there

Status
Not open for further replies.

ProgramError

Programmer
Mar 2, 2005
1,027
GB
I'm using the following code to assign a value to txtdiskno which is a textbox on a report. but I get a application-defined or object-defined error. the textbox is definately called txtdiskno and is unbound. when i do a debug.print rpt.name it gives me the correct name of the report.
Any ideas?
Code:
Function LabelCopies(rpt As Report)

  rpt.txtDiscNo = CopyCount&
  Debug.Print rpt.txtDiscNo

  If CopyCount& < (Copies& - 1) Then
    rpt.NextRecord = False
    CopyCount& = CopyCount& + 1
  End If
  Debug.Print CopyCount&

End Function

Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
What is CopyCount& ??
Can you get rid of the & characters in your variable names?
Also try changing rpt.txtDiscNo = CopyCount&
to txtDiscNo = CopyCount&


The early bird may get the worm, but the second mouse gets the cheese in the trap.
 
I found this label duplication and skip label routine on this link on the MS web site and adapted it just to my needs and this is causing the problem which I can't sort out.


This is a function in a module and not in the report so the removal of rpt will cause the routine not to see the report being accessed. not the delaration of the variable in the header of the fuuction (rpt as report). I will try it anyway.

As for Copycount&, this is a shorthand way of typing dim copycount as integer. Try it!


Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
the textbox is definately called txtdiskno

but in your code

Code:
rpt.txtDis[COLOR=red]c[/color]No = CopyCount&

And just for giggles, try replacing CopyCount& with a normally declared integer:
Code:
Dim CopyCount As Integer

I've never seen or heard of appending an ampersand to a variable declare an integer, and a quick Google search did not enlighten me.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top