User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 455,968 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,739 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 944 | Replies: 8
Reply
Join Date: Oct 2007
Posts: 9
Reputation: TOROOOLOLOOLO is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
TOROOOLOLOOLO TOROOOLOLOOLO is offline Offline
Newbie Poster

Help Synthax for finding a record:Re

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2007
Posts: 144
Reputation: hopalongcassidy is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 13
hopalongcassidy's Avatar
hopalongcassidy hopalongcassidy is offline Offline
Junior Poster

Re: Synthax for finding a record:Re

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

Call MsgBox("Sorry, there is no such record found in the database with Employee ID :" & _
Trim(txtsearch.Text) & "." & vbCrLf & "Please try again...", vbExclamation, "Employee")
Reply With Quote  
Join Date: May 2007
Location: India
Posts: 501
Reputation: choudhuryshouvi is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 48
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: Synthax for finding a record:Re

  #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  
Join Date: Oct 2007
Posts: 9
Reputation: TOROOOLOLOOLO is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
TOROOOLOLOOLO TOROOOLOLOOLO is offline Offline
Newbie Poster

Re: Synthax for finding a record:Re

  #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  
Join Date: Apr 2007
Posts: 69
Reputation: SCBWV is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 9
SCBWV SCBWV is offline Offline
Junior Poster in Training

Re: Synthax for finding a record:Re

  #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  
Join Date: May 2007
Location: India
Posts: 501
Reputation: choudhuryshouvi is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 48
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Solution Re: Synthax for finding a record:Re

  #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  
Join Date: Oct 2007
Posts: 9
Reputation: TOROOOLOLOOLO is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
TOROOOLOLOOLO TOROOOLOLOOLO is offline Offline
Newbie Poster

Re: Synthax for finding a record:Re

  #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  
Join Date: Apr 2007
Posts: 69
Reputation: SCBWV is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 9
SCBWV SCBWV is offline Offline
Junior Poster in Training

Re: Synthax for finding a record:Re

  #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  
Join Date: May 2007
Location: India
Posts: 501
Reputation: choudhuryshouvi is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 48
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Solution Re: Synthax for finding a record:Re

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 9:10 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC