Synthax for finding a record:Re

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2007
Posts: 16
Reputation: TOROOOLOLOOLO is an unknown quantity at this point 
Solved Threads: 0
TOROOOLOLOOLO TOROOOLOLOOLO is offline Offline
Newbie Poster

Synthax for finding a record:Re

 
0
  #1
Nov 23rd, 2007
Hi
I am still facing problems after writing the codes for finding a record. A compile error occurs, which says
"User-defined type not defined" .I don't understand what it means or even how to go about it. please i need help.The following are the codes i wrote for the program;

Option Explicit

Dim db As Database
Dim rs As Recordset

Private Sub cmdsearch_Click()
If Trim(txtsearch.Text) <> "" Then
Set rs = db.OpenRecordset("select * from details where id='" & Trim(txtsearch.Text) & "'")
If rs.RecordCount > 0 Then
txtid.Text = rs!id
txtname.Text = rs!Name
txtbasic.Text = rs!basic
txtsearch.SelStart = 0
txtsearch.SelLength = Len(Trim(txtsearch.Text))
txtsearch.SetFocus
Else
MsgBox "Sorry, there is no such record found in the database with Employee ID :" & _
Trim(txtsearch.Text) & "." & vbCrLf & "Please try again...", vbExclamation, "Employee"
txtid.Text = ""
txtname.Text = ""
txtbasic.Text = ""
txtsearch.SelStart = 0
txtsearch.SelLength = Len(Trim(txtsearch.Text))
txtsearch.SetFocus
End If
Else
MsgBox "Please mention the employee id to search for.", vbExclamation, "Employee"
txtsearch.SetFocus
End If
End Sub

Private Sub Form_Load()
Set db = OpenDatabase(App.Path & "\employee.mdb")
Set rs = db.OpenRecordset("details", dbOpenTable)

If rs.RecordCount > 0 Then
rs.MoveFirst
Else
MsgBox "Please add some records to the database before you try to search.", vbInformation, "Employee"
End If
End Sub
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 147
Reputation: hopalongcassidy is an unknown quantity at this point 
Solved Threads: 13
hopalongcassidy's Avatar
hopalongcassidy hopalongcassidy is offline Offline
Junior Poster

Re: Synthax for finding a record:Re

 
0
  #2
Nov 23rd, 2007
Your problem is on the MsgBox. Try the following:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Call MsgBox("Sorry, there is no such record found in the database with Employee ID :" & _
  2. Trim(txtsearch.Text) & "." & vbCrLf & "Please try again...", vbExclamation, "Employee")
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 537
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: Synthax for finding a record:Re

 
0
  #3
Nov 24th, 2007
hi TORO it's Shouvik again. i think that is my code which i posted to ur previous thread. here is the answer for ur question :-

there is no error in the above code at all. all the syntaxes and calling procedures,functions are absolutely correct. the msgbox callout is also completely ok. u have the problem in the dao reference which u have forgotten to include into ur project.to add it goto project->references, scroll down and select "Microsoft DAO 3.51 Object Library" and click ok. after this run the program and there will be no error at all. it's a promise. and by the way thanks for ur comment for my reply to ur previous post. keep contacting me.

regards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 16
Reputation: TOROOOLOLOOLO is an unknown quantity at this point 
Solved Threads: 0
TOROOOLOLOOLO TOROOOLOLOOLO is offline Offline
Newbie Poster

Re: Synthax for finding a record:Re

 
0
  #4
Nov 26th, 2007
Thanks Shouvk for the support, but still there is a problem when i run the program. A run-time error '3343': occurs. It says "unrecognised database format 'C:\Documents and Settings\Sugar\My Documents\VBpro\toroo\Employee.mdb ' .
Need help to fix this problem.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 103
Reputation: SCBWV is an unknown quantity at this point 
Solved Threads: 15
SCBWV SCBWV is offline Offline
Junior Poster

Re: Synthax for finding a record:Re

 
0
  #5
Nov 26th, 2007
What database version format are you using? What version of DAO are you using?

Also, if you're working strictly with strings, you should use the specific versions of Left$(), Mid$(), Right$(), Chr$(), ChrW$(), UCase$(), LCase$(), LTrim$(), RTrim$(), Trim$(), Space$(), String$(), Format$(), Hex$(), Oct$(), and Str$().

Otherwise, VB uses the Variant version, which is much slower.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 537
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: Synthax for finding a record:Re

 
0
  #6
Nov 27th, 2007
Originally Posted by TOROOOLOLOOLO View Post
Thanks Shouvk for the support, but still there is a problem when i run the program. A run-time error '3343': occurs. It says "unrecognised database format 'C:\Documents and Settings\Sugar\My Documents\VBpro\toroo\Employee.mdb ' .
Need help to fix this problem.
have you created the database by using ms-access software of versions higher than office 97???
if yes then i'm sorry to say that you cannot access the database from vb. because vb6 has the limitation on accessing the Access databases rather than office97 format. in such circumstances you have to create the database using vb6's visual data manager. then there will be no problem in accessing the database from your vb program. now if you don't wish to do this then you need to install the service pack 4 patch of vb6. visit the following link to get the vb6 service pack 6 files :- http://www.microsoft.com/downloads/d...displaylang=en

after you have downloaded the above file, install it and then try to run your program. there should not be any problem now.

regards
Shouvik
Last edited by choudhuryshouvi; Nov 27th, 2007 at 12:05 pm.
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 16
Reputation: TOROOOLOLOOLO is an unknown quantity at this point 
Solved Threads: 0
TOROOOLOLOOLO TOROOOLOLOOLO is offline Offline
Newbie Poster

Re: Synthax for finding a record:Re

 
0
  #7
Nov 27th, 2007
Thanks Shouvik, can you please give me guidelines on how to use vb6's visual data manager to create the database.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 103
Reputation: SCBWV is an unknown quantity at this point 
Solved Threads: 15
SCBWV SCBWV is offline Offline
Junior Poster

Re: Synthax for finding a record:Re

 
0
  #8
Nov 27th, 2007
VB6 can use Access files in other versions. I do it all the time with Access 2000 and 2003. You just have to load the correct DAO version.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 537
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: Synthax for finding a record:Re

 
0
  #9
Nov 29th, 2007
Originally Posted by TOROOOLOLOOLO View Post
Thanks Shouvik, can you please give me guidelines on how to use vb6's visual data manager to create the database.
it's a long time process. have you tried your program after downloading and installing the patch files yet??? first try it and if it won't work i'll surely tell you the steps.

regards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC