Office中国论坛/Access中国论坛

标题: 超级难题,求大哥级解答 [打印本页]

作者: mmteaa    时间: 2012-6-12 13:42
标题: 超级难题,求大哥级解答

主窗体代码:
Private Sub Command39_Click()
Me.Text32.Value = Me.Text1.Form.照片编号
Form_Current
End Sub

Private Sub Form_Current()
         If Dir(CurrentProject.Path & "\photo\" & Me.Text32 & ".jpg") = "" Then
            Image12.Picture = CurrentProject.Path & "\" & "err.jpg"
        Else
            Image12.Picture = CurrentProject.Path & "\photo\" & Me.Text32 & ".jpg"
        End If
End Sub

只有按command39,照片才能显示,我想点击子窗体的记录,直接就能显示照片,请问代码怎么加呀

子窗体代码:
Private Sub 照片编号_Click()
Me.Parent.Text32 = Me.照片编号
End Sub
[attach]49338[/attach]
作者: 13601812106_01    时间: 2012-6-12 13:58
Private Sub 代码_DblClick(Cancel As Integer)
Shell "rundll32.exe shimgvw.dll,imageview_fullscreen " & Me.照片图像.Picture   ' 调用 windows 图片和传真查看器打开图片
   
End Sub
Private Sub Form_Current()                                      '切换记录时会触发成为当前事件
    Dim 路径名 As String
    Dim Y As String
   
   
    Me!照片图像.Picture = ""                                    '先清除图像
   
        Y = "\\192.168.1.254\技术课\技术图纸\"
   
        路径名 = Y & Me!客户 & "\" & Me!代码 & ".jpg"       '生成照片路径名
        Me!照片图像.Picture = ""                                '清除图像
        
           If Dir(路径名) <> "" Then                               '判断照片是否存在,如果照片存在
            Me!照片图像.Picture = 路径名                        '将图片加载到图像控件
               
        End If
      
End Sub
作者: 13601812106_01    时间: 2012-6-12 13:59
参考我的吧,本来也不难的

作者: mmteaa    时间: 2012-6-12 14:10
多谢,回来试
作者: layaman_999    时间: 2012-6-12 15:39
本帖最后由 layaman_999 于 2012-6-12 15:42 编辑

Private Sub 照片编号_Click()
dim Frm as form
dim StrPIC as string
set frm=Me.Parent
strpic =nz( Me.照片编号,"")
frm.Text32 = strpic
        If Dir(CurrentProject.Path & "\photo\" & strpic  & ".jpg") = "" Then
            frm.Image12.Picture = CurrentProject.Path & "\" & "err.jpg"
        Else
            frm.Image12.Picture = CurrentProject.Path & "\photo\" & strpic  & ".jpg"
        End If
End Sub

作者: mmteaa    时间: 2012-6-12 16:23
多谢楼上二位,搞定了,下面是浪淘沙给的代码:
把主子窗体代码都删除,子窗体加如下代码

Private Sub Form_Current()

If Dir(CurrentProject.Path & "\photo\" & Me.照片编号 & ".jpg") = "" Then
   me.parent.form.Image12.Picture = CurrentProject.Path & "\" & "err.jpg"
Else

  me.parent.form.Image12.Picture = CurrentProject.Path & "\photo\" & Me.照片编号 & ".jpg"
End If
End Sub


作者: 老虎是我的    时间: 2012-6-12 17:16
神马 看不懂啊 哎




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3