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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW to use a variable instead path to view my Image from disk 1

Status
Not open for further replies.

124

Technical User
Feb 20, 2002
1
GB

How can I define a variable pointing at my fiel in my database instead usind direct path to my image in the disk?

Private Sub Report_Open(Cancel As Integer)
Me.Image28.Picture = "F:\fotos\1006094305.gif"

****E.G.*****
'Me.Image28.Picture = "F:\fotos\" & FieldName & ".jpg"
End Sub
 
Below are functions that will call the Database Properties to get your stored variables. To set this up you need to have your dataasbe open then go to file then to Database Properties then to the Custom tab. At that point you Need to type in the Name strFileName then in the value box type the name of your file. Then Click the Add button. Then in the Name Box Type strFilePath. Then in the Value box type in the directory your file is in then click ok.

The Functions hilighted in blue and green should be put in a module.

Function ap_GetDatabaseProp(dbDatabase As Database, strPropertyName As String) As Variant

ap_GetDatabaseProp = dbDatabase.Containers!Databases _
.Documents("UserDefined").Properties(strPropertyName).Value

End Function


Sub ap_SetDatabaseProp(dbDatabase As Database, strPropertyName As String, varValue As Variant)

dbDatabase.Containers!Databases.Documents("UserDefined").Properties(strPropertyName).Value = varValue

End Sub



this section of code needs to be wherever you use your hard coded file location at.
It also demostrates how to use the ap_GetDatabaseProp function.

you would ude the set database function in the same way to change the database property variables

Set dbLocal = CurrentDb()

pstrAppPath = CurrentProject.Path
pstrBackEndName = ap_GetDatabaseProp(dbLocal, "strFileName")
pstrBackEndPath = ap_GetDatabaseProp(dbLocal, "strFilePath")


HTH

If you need any more help with this let me know. ToeShot@Hotmail.com

Post Problems at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top