RE:Cargar las imagenes de una BD access
Publicado por
Eduardo (1 intervención) el 26/07/2006 03:16:35
amigo creo que tepuedo ayudar con tu problema.
Dim rutaimg As String
Private Sub Command1_Click()
Data1.Recordset.AddNew
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text1.SetFocus
Command1.Enabled = False
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = False
Command5.Enabled = True
End Sub
Private Sub Command2_Click()
Busqueda = InputBox("Cod to Find", "Find Cod")
If Busqueda <> "" Then
Data1.Refresh
With Data1.Recordset
.FindFirst "sn = '" & Busqueda & "'"
If .NoMatch Then
MsgBox "File Doesn't Found", vbCritical, "System Warning"
End If
End With
End If
End Sub
Private Sub Command3_Click()
Data1.Recordset("PHOTO") = rutaimg
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or Text8.Text = "" Then
MsgBox "You Need to Write all Fields", vbCritical, "System Warning"
Text1.SetFocus
End If
On Error GoTo a:
Data1.UpdateRecord
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
a:
If Err = 524 Then
MsgBox " The Serial Panel already Exists Tries To change", vbCritical, "System Warning"
Text1.SetFocus
End If
End Sub
Private Sub Command4_Click()
With Data1.Recordset
.Delete
.MoveNext
If .EOF Then .MoveLast
End With
End Sub
Private Sub Command5_Click()
If MsgBox("Do you want close this Windows?", 33, "Exit") = vbOK Then
Menu.Show
Bad_Panels.Hide
End If
End Sub
Private Sub Command7_Click()
cd1.Filter = "*.jpg;*.bmp"
cd1.ShowOpen
rutaimg = cd1.FileName
Image1.Picture = LoadPicture(Trim(rutaimg))
End Sub
Private Sub Data1_Reposition()
On Error GoTo a
If Data1.Recordset("photo") <> "" Then
Image1.Picture = LoadPicture(Trim(Data1.Recordset("photo")))
Else
Image1.Picture = LoadPicture("")
End If
a:
If Err = 3021 Then
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Do you want close this Windows?", 33, "Exit") = vbOK Then
Menu.Show
Bad_Panels.Hide
End If
End Sub
este es todo el codigo de mi formulario te digo que el base de datos yo utilice un campo de texto para guardar las fotos( esta rutina guarda la direccion de donde tienes la foto y la relaciona con todos los demas datos que tengas.