mercredi 25 avril 2007

How to open a Attachement

Following code will shoe how to open a attachement stored in a table.

this need a table with a attachment field and a active form created on the table.


Dim varRet
dim form1,rec,flid
dim formID,recId,fieldId
dim strURL
dim intURL
dim tableName,fieldName,strStringTosearch,vntAttachementField,strActiveFormName



intURL=left(UIMaster.RSysClient.InitialUrl,instrrev(UIMaster.RSysClient.InitialUrl,"/"))

With UIMaster.RSysClient

varRet=.SQLSearch(.GetTable(tableName).Fields(fieldName).FieldId,strStringTosearch,.GetTable(tableName).Fields(vntAttachementField).FieldId)

'the idea here to get the binary id of the attachment for a searched record,searching the fieldName with strStringTosearch string,and return the binary value of the attachment field value

set form1=.getForm(strActiveFormName)
formID=.idtostring(form1.FormID)
recId=.idtostring(varRet)

'u need the field id as well
fieldId=.idtostring(.GetTable(tableName).Fields(vntAttachementField).FieldId)
strURL=intURL & "AttachmentServer.asp?System=" & UIMaster.RSysClient.SystemName & ""
strURL= strURL& "&FormId=" & formID
strURL= strURL& "&FieldId=" & fieldId
strURL= strURL& "&RecordId=" & recId
UIMaster.ShowURL actionAutoSave, strURL, ""


End with

Aucun commentaire: