Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

running queries from vb
i am trying to run a query that will allow the user to search from a
particular contact title by the first letter. When a letter is entered, i
want to be able to  return only all contact title names, as well as the
number of times the contact title appear within that table. return the
contact title itself as well as the number of times it appeared in the
database.  however i must mention that the customer table is linked to
another table by the id.
for example customer.id = order.id, then show all the contact
titles(hopefully you understand what i am trying to do).
I just don't know how to show all of this using vb.If someone could help me
I would greatly appreciate it.

Thanks, Squeakie

This is what I have so far.


'Written in VB 6.0.
'The menu editor was used on the form instead of using command buttons.
 '=======================================
========================
Option Explicit
Public db As Database
Public rstCustomers As Recordset
'Run this sub on startup.
Private Sub Form_Load()
Set db = OpenDatabase("a:\Summing.mdb")
With db

Set rstCustomers = .OpenRecordset("Customers")
Label1.Caption = rstCustomers.RecordCount & " records"
If rstCustomers.RecordCount = 0 Then Exit Sub
With rstCustomers
.Edit
Text1.Text = !CompanyName
Text2.Text = !ContactName
Text3.Text = !ContactTitle
Text4.Text = !Address
Text5.Text = !City
Text6.Text = !Country
Text7.Text = !Phone

End With
End With
End Sub


'This steps forward in the file.  Check for a EOF (end of file)
'status of true, if true, stay at last record, else display it.
Private Sub Next_Click()
With rstCustomers
.MoveNext
If rstCustomers.EOF Then
MsgBox "You are at the end of the file.", vbOKOnly, "  Error!"
.MoveLast
Exit Sub
Else
.Edit
Text1.Text = !CompanyName
Text2.Text = !ContactName
Text3.Text = !ContactTitle
Text4.Text = !Address
Text5.Text = !City
Text6.Text = !Country
Text7.Text = !Phone


End If
End With
End Sub
'This steps backward in the file.  Check for a BOF (beginning of file)
'status of true, if true, stay at first record, else display it.
Private Sub Previous_Click()
With rstCustomers
.MovePrevious
If rstCustomers.BOF Then
MsgBox "You are at the beginning of the file.", vbOKOnly, "  Error!"
.MoveFirst
Exit Sub
Else
.Edit
Text1.Text = !CompanyName
Text2.Text = !ContactName
Text3.Text = !ContactTitle
Text4.Text = !Address
Text5.Text = !City
Text6.Text = !Country
Text7.Text = !Phone

End If
End With
End Sub
'Close database and end the program.
Private Sub Exit_Click()
db.Close
End
End Sub

--
squeakie - forum member
http://www.visual-basic-data-mining.net/forum



Report this thread to moderator Post Follow-up to this message
Old Post
http://www.visual-basic-data-mining.net/forum
10-29-04 01:55 AM


Re: running queries from vb
"http://www.visual-basic-data-mining.net/forum" <simiking@gmail.com> wrote
in message news:uJxMAYTvEHA.1292@TK2MSFTNGP10.phx.gbl...

>    With rstCustomers
>        .Edit
>        Text1.Text = !CompanyName

There's no need to put the recordset into edit mode to READ from it.

In order to answer your main question, I thought I understood what you meant
until you got to

> however i must mention that the customer table is linked to
> another table by the id.
> for example customer.id = order.id, then show all the contact
> titles(hopefully you understand what i am trying to do).

That's where you lost me. Let us know what fields are in your tables and
what fields you'd like to see returned by the query (or queries?).



Report this thread to moderator Post Follow-up to this message
Old Post
Jeff Johnson [MVP: VB]
10-29-04 08:55 AM


Re: running queries from vb
On Thu, 28 Oct 2004 16:45:28 -0500,
http://www.visual-basic-data-mining.net/forum <simiking@gmail.com>
wrote:
> i am trying to run a query that will allow the user to search from a
> particular contact title by the first letter. When a letter is entered, i
> want to be able to  return only all contact title names, as well as the
> number of times the contact title appear within that table. return the
> contact title itself as well as the number of times it appeared in the
> database.  however i must mention that the customer table is linked to
> another table by the id.
> for example customer.id = order.id, then show all the contact
> titles(hopefully you understand what i am trying to do).
> I just don't know how to show all of this using vb.If someone could help m
e
> I would greatly appreciate it.

What I did was build a query tester.

I used a data-bound list bound to an ADO control, with a text box
feeding queries to the ADO control.

Now if I just could stop using reserved words as field names . . .


Report this thread to moderator Post Follow-up to this message
Old Post
U-CDK_CHARLES\\Charles
10-29-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:11 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.