acOLECreateLink

S

Senad Isanovic

I have activeX field in the database and controller in the form. There is
Insert image button on the form with this code

Private Sub cmdFigur_Click()
On Error GoTo Err_cmdFigur_Click

Me.Figur.SetFocus

Dim sBild As String
Dim sSokvag As String
sSokvag = DLookup("Sokvag", "Sokvagar", "[Funktion]='Infoga figur'")
sSokvag = sSokvag & ""
If sSokvag = "" Then
If MsgBox("Du har inte angett någon sökväg för bildfiler." & vbCrLf &
"Vill du göra det nu?", vbYesNo + vbInformation) = vbYes Then
DoCmd.OpenForm "frmSokvagar", , , "Funktion='Infoga figur'"
End If
Else
sBild = fGetBild(sSokvag)
If Not sBild = "" Then
Figur.OLETypeAllowed = acOLELinked
Figur.SourceDoc = sBild
Figur.Action = acOLECreateLink
End If
End If

Exit Sub

'Figur.Action = acOLECreateFromFile


DoCmd.RunCommand acCmdInsertObject

Exit_cmdFigur_Click:
Exit Sub

Err_cmdFigur_Click:
If err.Number = 94 Then
Resume Next
Else
MsgBox err.Description & err.Number
Resume Exit_cmdFigur_Click
End If


End Sub

Public Function fGetBild(sSokvag As String)
Dim strFilter As String
Dim lngFlags As Long
Dim sStartPath As String
strFilter = ahtAddFilterItem(strFilter, "Grafikfiler (*.wmf; *.emf;
*.dib; *.bmp; *.gif; *.jpg; *.jpeg)", "*.wmf; *.emf; *.dib; *.bmp; *.gif;
*.jpg; *.jpeg")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
sStartPath = sSokvag 'CurrentProject.Path
fGetBild = ahtCommonFileOpenSave(InitialDir:=sStartPath,
Filter:=strFilter, FilterIndex:=1, _
Flags:=lngFlags, DialogTitle:="Välj bild")
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
End Function

Error message is generate on the line

Figur.Action = acOLECreateLink

Error number 2753, "Communication error between database and ActiveX
control..." And I cannot see why? I'm using Win XP, Office 2003. It works
just fine on the one machine but not on the other (with the same version of
Office2003).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top