Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 18th, 2006, 12:43 PM
Registered User
 
Join Date: Oct 2006
Location: muhrraq, , Bahrain.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default adodc and flexgrid!

hi dears:) i'm new here, i'm doing a softwaer for my company and i have an adodc control attached to some text fields, one of the text fields(ex:location)may have more than one value with the same name and my company askd me to make it as follow:

when u type in the location field and press enter it should check if the value in the field exisit more than onece if it dose it should cralte a flexgrid to show the records of the search key location which they r more than one. but if it is one only its easy it come by it self.

my code is:

Private Sub Text3_KeyPress(KeyAscii As Integer)

Dim i
If KeyAscii = 13 Then
Dim SQL As String
''Adodc1.Recordset.Update
'This specifies the SQL to be executed
SQL = "select * from PPD where location='" & Text3.Text & "'"
'This specifies that the type of the ADODC is for SQL
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = SQL
Adodc1.refresh
If Adodc1.Recordset.RecordCount > 1 Then

''Adodc1.Recordset.MoveFirst

MsgBox "THIS LOCATION NO. CONTAINS MORE THAN ONE RECORD DO YOU WANT TO SEE ? "

''Adodc1.Recordset.MoveLast
Do Until Adodc1.Recordset.EOF
Set frmppdsame.grdvalues.DataSource = Adodc1

Adodc1.Recordset.MoveNext

Loop
End If
'This assigns the SQL result to the ADODC


End If
End Sub

i know its wrong..cos i dont know how to join the adodc with the flexgrid. and pls show how to it it in data grid to.
sorry for the long article.

Reply With Quote
  #2 (permalink)  
Old October 18th, 2006, 12:51 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there...

since you are using ado, your record count will never be > 1 ;) Recordcount is 0 or 1 depends if you have or not have records...

try taking out that and see what happend.. the code doesn't look bad (at least at the fly)....

HTH

Gonzalo
Reply With Quote
  #3 (permalink)  
Old October 18th, 2006, 12:59 PM
Registered User
 
Join Date: Oct 2006
Location: muhrraq, , Bahrain.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i removed it and also canged it to 1..nothing happens but when i removed it it gave me this error: error '91'! pls if u can just exlan for me how to do it.. and try to fix my code..

Reply With Quote
  #4 (permalink)  
Old October 18th, 2006, 01:03 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

where did you receive the error 91???

unless I miss something, the do until can be removed, too...

this line
Code:
Set frmppdsame.grdvalues.DataSource = Adodc1
bind the grid to the recordset... also do a refresh in the grid...

also: do you have key preview in true?? to catch every key stroke, but it a bad idea to fill the grid that way, you will requery the table in every key stroke!

HTH

Gonzalo
Reply With Quote
  #5 (permalink)  
Old October 18th, 2006, 01:10 PM
Registered User
 
Join Date: Oct 2006
Location: muhrraq, , Bahrain.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanx..for ur patients..

the error is in the same line Set frmppdsame.grdvalues.DataSource = Adodc1,what do u mean by key prewview in quarry!

Reply With Quote
  #6 (permalink)  
Old October 18th, 2006, 01:19 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

ok.. breath.. let's go slow here..

are you using a datagrid?? or a flexgrid?? why not use the datagrid if you are binding it to a data control??
the key press event fires every time the user press a key but if the control doesn't have a key press event itself, if so you have to put in true the keypreview property of the form.

you are in VB 6, aren't you???




HTH

Gonzalo
Reply With Quote
  #7 (permalink)  
Old October 18th, 2006, 01:33 PM
Registered User
 
Join Date: Oct 2006
Location: muhrraq, , Bahrain.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

no it dose have a keypress...! its a text field! and its ok for me to use the datsagird as long as satisfies my need but i dont know the coding..and how to bound i tried the same thing set formname.datagri1.datasource= adodc1 and it didnt worked:(


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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with ADODC and Access fm2005 Pro VB Databases 5 June 11th, 2007 07:20 AM
ADODC PROBLEM cnkumar74 VB Components 0 February 16th, 2007 03:27 AM
Trouble with ADODC ctrl nav1 VB How-To 3 June 21st, 2005 09:19 AM
Adodc records navigation prognoobie VB How-To 1 May 6th, 2004 01:39 PM
Datagrid and ADODC cindy Beginning VB 6 1 November 11th, 2003 04:28 AM



All times are GMT -4. The time now is 09:50 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.