Fran Smith
New member
- Local time
- Tomorrow, 06:58
- Joined
- Oct 15, 2011
- Messages
- 8
Hi,
I have a field in a table which I would like to populate my attachment control on my form with. Actually, I'm not even sure if an attachment is the right field type. I want the user to be able to select and save an image, but I also want to be able to populate user's saved images on the form. I use DAO - it's the only record system I know. Unfortunately, my searches for information on how to achieve this only seems to find ADO, which I'm unfamilar with. I did find one page which helped vaguely with code for saving, but not retrieving. Here is what I have - I know it's probably not close, but I'm a beginner:
' Populate Mother on the Family Form
Dim db As DAO.Recordset
Dim rst As Recordset
Dim rstAtt As Recordset
Dim rstCount As Integer
Set rst = CurrentDb.OpenRecordset("SELECT ID, Name, Picture, Age, Gender FROM People WHERE Gender='Female' AND Age='Young Adult'")
rstCount = rst.RecordCount
If rstCount <> 0 Then
Me.txtMother = rst!Name
Set rstAtt = rst.Fields("Picture").Value
Me.attMother = rstAtt.Fields("FileData")
rst.Close
rstAtt.Close
Else
Me.txtMother.Visible = False
Me.attMother.Visible = False
End If
Set db = Nothing
Set rst = Nothing
What do I do to get it to load the correct picture that goes with the text field (which does load fine)?
I have a field in a table which I would like to populate my attachment control on my form with. Actually, I'm not even sure if an attachment is the right field type. I want the user to be able to select and save an image, but I also want to be able to populate user's saved images on the form. I use DAO - it's the only record system I know. Unfortunately, my searches for information on how to achieve this only seems to find ADO, which I'm unfamilar with. I did find one page which helped vaguely with code for saving, but not retrieving. Here is what I have - I know it's probably not close, but I'm a beginner:
' Populate Mother on the Family Form
Dim db As DAO.Recordset
Dim rst As Recordset
Dim rstAtt As Recordset
Dim rstCount As Integer
Set rst = CurrentDb.OpenRecordset("SELECT ID, Name, Picture, Age, Gender FROM People WHERE Gender='Female' AND Age='Young Adult'")
rstCount = rst.RecordCount
If rstCount <> 0 Then
Me.txtMother = rst!Name
Set rstAtt = rst.Fields("Picture").Value
Me.attMother = rstAtt.Fields("FileData")
rst.Close
rstAtt.Close
Else
Me.txtMother.Visible = False
Me.attMother.Visible = False
End If
Set db = Nothing
Set rst = Nothing
What do I do to get it to load the correct picture that goes with the text field (which does load fine)?