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!

Help with fields in reports 1

Status
Not open for further replies.

tonybli

Technical User
Nov 14, 2007
4
US
Hey All -

Ok first let me say I'm new to access so go easy...

I have some experience with VB6.

My issue - I have an VB6 program that uses data in an access table. When it's time to print the vb6 app opens an instance of access and the needed report (all is well up to this point).
The vb app writes a sql statement to a txt file. When the access report opens it reads the text file and gets the record source from the sql statement (I'm sure there is a better way to do that, but I'm a noob and thats what I came up with)

Anywhoo...So now my problem...I have images outside of access that I want to load into an image container on the report for each record that prints. I can load the image no problem if I hard code the path but thats not what I want to do...I want to get the value of the fldAutoNumber which cooresponds to the image name. (I would think it would be super easy to get the info. But I can't remember being this frustrated in a long time) I keep getting an error message that says it can't find the field "fldAutoNumber". So I don't know if it's the syntax or what... I have included all fields in the sql statement. If I type me and then the period the field name even shows up in the drop down list so I'm getting p$$$$$. If someone could give me some pointers on something like:
Me![Image1].Picture = "x:\dataloc\" & Me![fldAutoNumber].value & ".bmp"

I would be very greatful. I'm sure this is way to much info but I don't normally post on boards I usually spend countless hours reading them :).
 
You suggest you are running code somewhere but we don't know where? Can you share all your code from the report?

If you want to set the picture property of an image control, you do this in the On Format event of the section containing the image control.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks for responding. The project is on a different computer but I will sum up as best I can.

When the report opens, so

Private Sub Report_Open(Cancel as Integer)
Dim x as Integer, sqlString as String, strTrimSql as String

Open "Y:\dataloc\Sometext.txt" For Input As #1
Line Input #1, strTrimSql
Close #1

x = Len(strTrimSql)
sqlString = Mid(strTrimSql, 2, x-2)

Me.RecordSource = sqlString

Me![Image1].Picture = Me![fldAutoNumber].Value

End Sub


I will write a loop to move the record set and load the different images based on the autonumber vaule but I haven't got it to work with one so I haven't gone that far. If I replace the Me![fldAutoNumber].Value with and actual path the image will load. Does that help?
 
Sorry I missed part

Me![Image1].Picture = "Y:\some loc\" & Me![fldAutoNumber].value & ".bmp"

is what it should've read.
 
The code should be in the On Format event of the report section that contains the image control. In addition [fldAutoNumber] should be a bound text box in the same section. It can be invisible.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Ahhhhhhhh...I thought I was going to have to slam my head into a window!!! You have saved me. And that event seems to fire every time the record changes so no loop required to load the image. That is pretty cool.. Thanks a lot for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top