Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 23rd, 2004, 05:52 PM
Lilibeta Lilibeta is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Toronto, Ontario
Posts: 29 Lilibeta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 10 sec
Reputation Power: 0
Question images in tables

I'm creating a simple application solely in Access.
The table consists of several fields such as Id, name, description etc. and image.

The idea is that as each new record is displayed in the form, the picture associated with that record is displayed. But I'm not sure how to enter image data into a table, nor can I get it to display on the form.

Anyone know?
Thanks,
Lilibeta

Reply With Quote
  #2  
Old January 24th, 2004, 02:28 AM
hajdardi hajdardi is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 5 hajdardi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I found this way of inserting images useful, take a look at the codes and functions and if you want a sample of it I can send it at your e-mail. it can display the images in the reports too.

Option Compare Database
Option Explicit

' Code to display standard "Open File" dialog.

Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type

Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (OFN As OPENFILENAME) As Boolean

Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias _
"GetSaveFileNameA" (OFN As OPENFILENAME) As Boolean

Private Const ALLFILES = "All files"

Function MakeFilterString(ParamArray varFilt() As Variant) As String
' Create filter string.
' Returns "" if there are no arguments.
' Expects an even number of arguments (filter name, extension).
' Adds *.* if the number of arguments is odd.

Dim strFilter As String
Dim intRes As Integer
Dim intNum As Integer

intNum = UBound(varFilt)
If (intNum <> -1) Then
For intRes = 0 To intNum
strFilter = strFilter & varFilt(intRes) & vbNullChar
Next
If intNum Mod 2 = 0 Then
strFilter = strFilter & "*.*" & vbNullChar
End If

strFilter = strFilter & vbNullChar
End If

MakeFilterString = strFilter
End Function

Private Sub InitOFN(OFN As OPENFILENAME)
With OFN
' Initialize fields user doesn't want to know about
.hwndOwner = hWndAccessApp
.hInstance = 0
.lpstrCustomFilter = vbNullString
.nMaxCustFilter = 0
.lpfnHook = 0
.lpTemplateName = 0
.lCustData = 0
.nMaxFile = 511
.lpstrFileTitle = String(512, vbNullChar)
.nMaxFileTitle = 511
.lStructSize = Len(OFN)
' Use default filter if not specified.
If .lpstrFilter = "" Then
.lpstrFilter = MakeFilterString(ALLFILES)
End If
' Pad lpstrFile with null chars.
.lpstrFile = .lpstrFile & String(512 - Len(.lpstrFile), vbNullChar)
End With
End Sub

Function OpenDialog(OFN As OPENFILENAME) As Boolean
Dim intRes As Integer
InitOFN OFN
intRes = GetOpenFileName(OFN)
If intRes Then
' Remove trailing null chars from lpstrFile.
With OFN
.lpstrFile = Left$(.lpstrFile, InStr(.lpstrFile, vbNullChar) - 1)
End With
End If
OpenDialog = intRes
End Function

'_____________________________

'The following subs are used on the form.
'_____________________________

'This sub is added to a Close Button.

'Private Sub cmdClose_Click()
' On Error Resume Next
' DoCmd.Close acForm, Me.Name

'End Sub
'_______________________________

'This button removes the picture
'Picfile is the name in TABLE
'imgPicture is the name of the field on the form

'Private Sub cmdErasePic_Click()

' If Not IsNull([PicFile]) Then
' If MsgBox("The image will be removed from this record. Are you sure?", vbYesNo + vbQuestion) = vbYes Then
' [imgPicture].Picture = ""
' [PicFile] = Null
' SysCmd acSysCmdClearStatus
' End If
' End If
'End Sub
'________________________________

'This sub is used together with module to open the dialog box

'Private Sub cmdInsertPic_Click()
' Dim OFN As OPENFILENAME
' On Error GoTo Err_cmdInsertPic_Click

' ' Set options for dialog box.
' With OFN
' .lpstrTitle = "Images"
' If Not IsNull([PicFile]) Then .lpstrFile = [PicFile]
' .flags = &H1804 ' OFN_FileMustExist + OFN_PathMustExist + OFN_HideReadOnly
' .lpstrFilter = MakeFilterString("Image files (*.bmp;*.gif;*.jpg;*.wmf)", "*.bmp;*.gif;*.jpg;*.wmf", _
' "All files (*.*)", "*.*")
' End With

' If OpenDialog(OFN) Then
' [PicFile] = OFN.lpstrFile
' [imgPicture].Picture = [PicFile]
' SysCmd acSysCmdSetStatus, "Afbeelding: '" & [PicFile] & "'."
' End If
' Exit Sub

'Err_cmdInsertPic_Click:
' MsgBox Err.Description, vbExclamation
'End Sub
'___________________________________

'This sub placed in the Form_Current section.

'Private Sub Form_Current()
' On Error GoTo HandleErr
' If Not IsNull([PicFile]) Then
' [imgPicture].Picture = [PicFile]
' SysCmd acSysCmdSetStatus, "Image: '" & [PicFile] & "'."
' Else
' [imgPicture].Picture = ""
' SysCmd acSysCmdClearStatus
' End If
' Exit Sub

'HandleErr:
' If Err = 2220 Then
' [imgPicture].Picture = ""
' SysCmd acSysCmdSetStatus, "Can't open image: '" & [PicFile] & "'"
' Else
' MsgBox Err.Description, vbExclamation
' End If
'End Sub

Reply With Quote
  #3  
Old January 24th, 2004, 09:14 AM
Lilibeta Lilibeta is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Toronto, Ontario
Posts: 29 Lilibeta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 10 sec
Reputation Power: 0
Wow! That's a little daunting!
I've never worked with the code in Access before.

Right about now I'm thinking that this would be a lot easier if I just did the database in Access and used Visual Basic for the forms. But I'll give this a try.
Thanks!

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > images in tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway