Ik heb onderstaande code nogmaals proberen in te voegen in mijn db. Standplaats zon is een tekstvak.
Ik krijg echter een aantal foutmeldingen:
1.
Private Sub Form_Load()
er is geen sub-form!
2.
Me.Foto.Value = Path & "\" & Me.OpenArgs
?? Kun je wat hints geven?
Private Sub Standplaats_zon_Click()
'Copyright: Allen Browne's Database And Training, 2007.
'Author: Allen Browne.
allen@allenbrowne.com
Option Compare Database
Option Explicit
' Only the first X bytes of the file are read into a byte array.
' BUFFERSIZE is X. A larger number will use more memory and
' be slower. A smaller number may not be able to decode all
' JPEG files. Feel free to play with this number.
Private Const BUFFERSIZE As Long = 65535
Dim ConMod
Dim Path As String
Dim iWidth As Long, iHeight As Long
Private Sub Form_Load()
Dim Path As String
Path = CurrentProject.Path
Dim smt() As String
If Not IsNull(Me.OpenArgs) Then
Me.Foto.Value = Path & "\" & Me.OpenArgs
smt = Split(ListImageDimensions(Me.Foto), "|")
DoCmd.MoveSize 5000, 400, (smt(0) * 8) + 100, (smt(1) * 8) + 300
Me.ImageFrame.Width = smt(0) * 8
Me.ImageFrame.Height = smt(1) * 8
''Me.ImageFrame.SizeMode = acOLESizeClip
''Me.ImageFrame.SizeMode = acOLESizeZoom
Me.ImageFrame.SizeMode = acOLESizeStretch
Me.Repaint
If (IsRelative(Me.Foto) = True) Then
Me.ImageFrame.Picture = Path & Me.Foto
Else
Me.ImageFrame.Picture = Me.Foto
End If
Else
MsgBox "Er is geen foto om te laten zien...", vbOKOnly
DoCmd.Close acForm, Me.Name
End If
End Sub
Private Sub cmdCancel_Click()
On Error GoTo Err_Handler
DoCmd.Close acForm, Me.Name, acSaveNo
Exit_Handler:
Exit Sub
Err_Handler:
Call LogError(Err.Number, Err.Description, ConMod & ".cmdCancel_Click")
Resume Exit_Handler
End Sub
Function IsRelative(fName As String) As Boolean
' Onwaar als resultaat geven als de bestandsnaam een station of UNC-pad bevat
IsRelative = (InStr(1, fName, ":") = 0) And (InStr(1, fName, "\\") = 0)
End Function
Private Sub Foto_AfterUpdate()
If (IsRelative(Me.Foto) = True) Then
Me![ImageFrame].Picture = Path & Me.Foto
Else
Me![ImageFrame].Picture = Me.Foto
End If
End Sub
Private Sub ImageFrame_Click()
DoCmd.Close acForm, Me.Name
End Sub
Function ImgDimension(img)
Dim myImg, fs
On Error Resume Next
iWidth = 9999
iHeight = 9999
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FileExists(img) Then Exit Function
Set myImg = LoadPicture(img)
iWidth = Round(myImg.Width / 26.4583)
iHeight = Round(myImg.Height / 26.4583)
Set myImg = Nothing
End Function
Function ListImageDimensions(sFoto As String) As String
Dim sFileName As String
Dim sPath As String
Dim sTemp As String
'' sPath = "F:\AT\TUIN EN KAS\MDB images planten bestand\database"
'' sFileName = Dir(sPath & "*.jpg")
sFileName = sFoto
'' While sFileName <> ""
ImgDimension sFileName
sTemp = iWidth & "|" & iHeight
'' Wend
ListImageDimensions = sTemp
End Function
Private Sub Knop730_Click()
Dim smt() As String
smt = Split(ListImageDimensions(Me.Foto), "|")
''Me.InsideHeight = smt(1) * 8
''Me.InsideWidth = smt(0) * 8
End Sub