PDA

Click to See Complete Forum and Search --> : Why?


GiD
Nov 28th, 1999, 03:17 AM
Can someone tell me what's wrong with this code and why it doesn't update the database?

Private Sub cmdPicture_Click()
Dim sFile As String
Dim db As Database
Dim rs As Recordset
With dlgCommonDialog
.DialogTitle = "Open"
.CancelError = False
.Filter = "BMP Files (*.BMP)|*.BMP"
.ShowOpen
sFile = .FileName
End With
frmMembers.Image1.Picture = LoadPicture(sFile)
frmMembers.lblPicturePath.Caption = sFile
Set db = OpenDatabase(App.Path & "\Members.mdb")
Set rs = db.OpenRecordset("MemberInfo", dbOpenDynaset)
rs.Edit
rs!PicturePath = sFile
Recordset("PicturePath") = Text1.Text
rs.Update
End Sub

GiD

Quadrex
Nov 28th, 1999, 04:10 AM
Looks alright but maybe its because in this line
rs!PicturePath = sFile
you've put a ! instead of a . try
rs.PicturePath = sFile

:) Hope this works :)



------------------
Quadrex
webmaster@quadrex.f9.co.uk
Quadrex Programming (http://www.quadrex.f9.co.uk)

GiD
Nov 28th, 1999, 04:24 AM
Nope that didn't do it....can anyone out there help out? I just can't seem to get the database to update? I keep getting an error that says the database is readonly but its not. I've checked!

GiD

Aaron Young
Nov 28th, 1999, 07:15 AM
Check the actual Read Attribute in the MDBs File Properties, could be it was left checked after a previous program crash?

Another possibility is that you have the DB open in something else and it's opened Exclusively.

------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

LG
Nov 28th, 1999, 08:33 AM
Hi,GiD.
Do you use ODBC? I had the same problem and I found on microsoft support page solution, you have to provide all 4 parameters in OpenRecordset.
Set rst=db.OpenRecordset _("TableName",dbOpenDynamic,0,dbOptimistic)
NOTE: You must supply a zero (0) for the Option argument.

Hope it help.
Larisa