0

The question:

What do i need to do so in my form I can use a comboBox and have it autofill a picture on both the form and table?

The info:

In Microsoft Access 2007, I have 1 table and 1 form. The table has all the info for name, phone, address, and picture and it all comes up right in the form. I have a ComboBox for com, fam1, fam2, and fam3, and when I select a name on the comboBox, it autofills the info on the table and form for the com, com phone,and com address, but not the picture. I'm thinking that I need to do some VB coding for the "on change" for the combobox. image 1 shows the format of the table. image 2 shows the format of the form.

Picture1 http://dplcollagentherapy.com/pic01.JPG

Picture2 http://dplcollagentherapy.com/pic02.JPG

4

2 回答 2

0

我能够弄清楚如何使用以下代码更新 com 电话和 com 地址。但是组合框不允许我将图片添加到第 3 列中,这会使这变得容易得多。我会在某个时候做一份报告,让报告查找图片可能更容易。不确定我会为查找使用什么编码。再次感谢你。 编码

Option Compare Database

Private Sub Combo30_Change()
Me.txtcomphone.Value = Me.Combo30.Column(1)
Me.txtcomaddress.Value = Me.Combo30.Column(2)
Me.com_picture = dlookup("name", "Elders", "Name=" & Com)
End Sub

Private Sub Combo32_Change()
Me.txtfam1phone.Value = Me.Combo32.Column(1)
Me.txtfam1address.Value = Me.Combo32.Column(2)
End Sub

Private Sub Combo48_Change()
Me.txtfam2phone.Value = Me.Combo48.Column(1)
Me.txtfam2address.Value = Me.Combo48.Column(2)
End Sub

Private Sub Combo56_Change()
Me.txtfam3phone.Value = Me.Combo56.Column(1)
Me.txtfam3address.Value = Me.Combo56.Column(2)
End Sub
于 2013-04-08T15:35:21.983 回答
0

我这样做的方式不是将实际图像放在表格中,而是将它们全部放在表单本身上。为每张图片分配其自己的唯一名称,该名称对应于与其关联的字段。每张图片都设置为不可见。然后在 VBA 中,您可以编写如下代码:

If Me.ComboBox = Name Then
Me.NamesPicture.Visible = True
Else
Me.NamesPicture.Visible = False
End If

您可以将所有图片堆叠在一起,VBA 运行非常流畅,我过去曾将它用于工作中的小型项目。希望这会有所帮助!:)

于 2013-04-17T23:17:05.633 回答