If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > Database problems

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-15-09, 05:25
wijnendael wijnendael is offline
Registered User
 
Join Date: Nov 2009
Posts: 4
Database problems

First hi to all forumites and hoping somebody can assist me with database problems i am having with my project. I am attempting to modify some code that i have downloaded and now getting numerous database problems that i cannot sem to resolve. The first is in the frmConEntryNew where i am trying to add images to the database but keep getting a error, if someone can point me in the right direction to resolve this it would be great. The next problem is when clicking a name from the home screen and trying to edit information in the database i get a error 3061 when changing text boxes i.e changing Email and then clicking any other box.
The project is attached and apologise for the mess it is in at the moment with lots of old forms and code still in he project that i do not want to remove until i have the new forms working.
Attached Files
File Type: zip 1_0_0009.zip (630.6 KB, 7 views)
Reply With Quote
  #2 (permalink)  
Old 11-24-09, 16:34
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,797
what kind of database?

which version of VB?
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Reply With Quote
  #3 (permalink)  
Old 11-24-09, 17:20
wijnendael wijnendael is offline
Registered User
 
Join Date: Nov 2009
Posts: 4
Hi,
the database is in access 2003 and i use VB6, the form with the problem is in the zip file.
Reply With Quote
  #4 (permalink)  
Old 11-25-09, 13:36
wijnendael wijnendael is offline
Registered User
 
Join Date: Nov 2009
Posts: 4
I now have the code saving the image in the database using the following code for saving and populating the listbox.
Private Sub Command1_Click()
On Error GoTo Command1_Click_Err 'Error Code Inserted: 11/8/2009 5:38:50 PM ----------ERR--

Const sMOD_NAME As String = "frmContEntryNew.cmdAddImage_Click"
''On Error GoTo Error_Handler
Dim mypicture As String
Dim FN As String
Dim filebinary As String
Dim imagename As String
imagename = Text1(0)
With Dlgs
.Filter = "(*.bmp;*.jpg;*.gif;*.dat;*.pcx)| *.bmp;*.jpg;*.gif;*.dat;*.pcx|(*.psd)|*.psd|(*.All files)|*.*"
.ShowOpen

If .fileName = "" Then Exit Sub
mypicture = .fileName
FN = .FileTitle
'Open File And Read as Binary
Open .fileName For Binary Access Read As #1
filebinary = Space(LOF(1))
Get #1, , filebinary
Close #1
Image2.Picture = LoadPicture(.fileName)
'Add File To DB
' code to add the image to the database and refill the listbox

With rspic
.AddNew
!Client = imagename
!Img_name = FN
!Image = filebinary
.Update
End With
Call GetAllFiles
End With
Exit Sub
Command1_Click_Err: 'Error Code Inserted: 11/8/2009 5:38:50 PM ----------ERR--
If Err <> 0 Then
TestProc_Err: 'Error Code Inserted: 2/4/98 9:12:54 p ----------ERR--
If Err <> 0 Then
frmError.ErrMsg "contact entry", "mTestEnd", Erl, Err
End If
End If
End Sub
Private Sub GetAllFiles()

200 On Error Resume Next
'code to load list box
Dim strSetting As String

362 strSetting = Text1(0)

364 SQL = "SELECT Client, Img_name, Image FROM pic "
365 SQL = SQL & "WHERE Client = " & strSetting & " "
370 List1.Clear
372 With rspic
373 If (.RecordCount > 0) Then
374 .MoveFirst
375 While Not .EOF
If !Client = Text1(0) Then
List1.AddItem !Img_name
End If
378 .MoveNext
379 Wend
380 End If
381 End With

End Sub

However i am unable to load the imagebox when i click a item in the listbox, my code is as follows can somebody please tell me where i have gone wrong

Private Sub List1_Click()
Call ViewPic
End Sub
'Sub added to show image when listbox is clicked AJD
Public Sub ViewPic()
'View Pic From DB
Dim OutFile As String
Dim strSql As String
With rspic
If (.RecordCount > 0) Then
.MoveFirst
While Not .EOF
If !Client = Text1(0) And !Img_name = List1.Text Then
Image1.Picture = !Image
End If
.MoveNext
Wend
End If
End With
End Sub
Reply With Quote
  #5 (permalink)  
Old 12-03-09, 09:54
wijnendael wijnendael is offline
Registered User
 
Join Date: Nov 2009
Posts: 4
How to Delete the records ?

I now have the above code working where it is saving the images and populating the list box, however i cannot figure out how to delete a selected name in the list box from the database can anybody please help me. The code i have so far is as below and i have now added a second command button (delete) but do not know how to code the button to delete the selected file.
Private Sub Command1_Click()
On Error GoTo Command1_Click_Err 'Error Code Inserted: 11/8/2009 5:38:50 PM ----------ERR--

Const sMOD_NAME As String = "frmContEntryNew.cmdAddImage_Click"
''On Error GoTo Error_Handler
Dim mypicture As String
Dim FN As String
Dim filebinary As String
Dim imagename As String
imagename = Text1(0)
With Dlgs
.Filter = "(*.bmp;*.jpg;*.gif;*.dat;*.pcx)| *.bmp;*.jpg;*.gif;*.dat;*.pcx|(*.psd)|*.psd|(*.All files)|*.*"
.ShowOpen

If .fileName = "" Then Exit Sub
mypicture = .fileName
FN = .FileTitle
'Open File And Read as Binary
Open .fileName For Binary Access Read As #1
filebinary = Space(LOF(1))
Get #1, , filebinary
Close #1
Image2.Picture = LoadPicture(.fileName)
'Add File To DB
' code to add the image to the database and refill the listbox

With rspic
.AddNew
!Client = imagename
!Img_name = FN
!Image = filebinary
.Update
End With
Call GetAllFiles
End With
Exit Sub
Command1_Click_Err: 'Error Code Inserted: 11/8/2009 5:38:50 PM ----------ERR--
If Err <> 0 Then
TestProc_Err: 'Error Code Inserted: 2/4/98 9:12:54 p ----------ERR--
If Err <> 0 Then
frmError.ErrMsg "contact entry", "mTestEnd", Erl, Err
End If
End If
End Sub
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On