5 replies
by timfox2
You can determine the value of the report's picture property (the path to the image object's actual image content) in an if statement, within the OnActivate event of the report when you open the report, as follows:
Private Sub Report_Activate() If txtImageToLoad = "Jenny" Then
imgSignature.Picture = "c:\JennySig.jpg"
ElseIf txtImageToLoad = "Bob" Then
imgSignature.Picture = "c:\BobSig.jpg"
Else
imgSignature.Picture = "c:\NoSig.jpg"
End If
End Sub
You could alternatively have two Signature image objects that you hide or show depending on the values in your text boxes.
Private Sub Report_Activate()
If txtImageToLoad = "Jenny" Then
imgJennySig.Visible = True
imgBobSig.Visible = False
imgNoSig.Visible = False
ElseIf txtImageToLoad = "Bob" Then
imgBobSig.Visible = True
imgJennySig.Visible = False
imgNoSig.Visible = False
Else
imgNoSig.Visible = True imgBobSig.Visible = False
imgJennySig.Visible = False
End If
End Sub
Hope this helps.
TimFox
by qps
by timfox2
OK - Fair enuff, but I'm not sure if there is an easier way than using the code that I provided!
I've written the code as if the text box on the report is named txtImageToLoad, that my name is Bob (c:\BobSig.jpg contains my signature) and Jenny is my co-worker, so you might still be able to use the code as follows:
See if this works for you:
1. Open the report in design mode and go to the report's properties (double-click in the box that intersects the two rulers.)
2. Go to the Eventstab and make OnActivate equal [EventProcedure].
3. Click the elipse (...) next to the drop-down arrow. (you should now be in a code window that might already have some code in it)
4. Paste the code that appeared as the first answer directly into the code window.
(if you've got this far, then you're doing well, but now comes a tricky bit)
5. Locate the name of the field that has your name appear when you view the actual report. (double-click on the text box and go to options tab of the properties window - it might be called text1 or text15 etc)
6. Substitute txtImageToLoad for the name of the text box that you have just got in step 5.
7. Substitute 'Bob' with the value that would appear in this field (ie - your name) when you view/print the report.
8. Substitute c:\BobSig.jpg with the image's filename that contains your signature.
9. Substitute 'Jenny' with the value that would appear in the field when your co-worker's name is used.
10. Substitute c:\JennySig.jpg with the image's filename that contains your co-worker's signature.
- (Almost) Finished -
The next Else part of the code is just to satisfy the possibility that neither Bob or Jenny might appear in the text box, so you can leave that bit out if you want.
- Finished! -
Let me know if this doesn't help, so I can send you an email (pls provide address) with an example.
Cheers
Tim
by qps
by qps
This discussion is closed to new replies.
Trending Software posts
Sort by Trending