Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this message"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?).
Post Follow-up to this messageOn 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 . . .
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.