Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 7th, 2005, 09:27 AM
daveclarkie daveclarkie is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Location: Manchester
Posts: 4 daveclarkie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 40 sec
Reputation Power: 0
Send a message via MSN to daveclarkie
Exclamation Looping

Hello

I am trying to write some code that loops, colating record information from
several tables.

There is a table called mortgage, and then 84 seperate tables named by postal area

so far i can get it to identify which of the 84 tables that record comes from and how
many records within that table match certain criteria. But what i would like it to do
find how many records match the criteria accross all of the databases in one count
the code i have so far is

Code:
Private Sub btnGetProfile_Click()
	Me.btnCount.Enabled = False
	Me.btnCountScore.Enabled = False
	Me.txtCameoCode.Text = ""
	Me.TxtCreditBand.Text = ""
	Me.txtYearsOfResidency.Text = ""
	Me.txtFamily.Text = ""
	Me.txtTPS.Text = ""
	Me.txtDead.Text = ""
	Me.txtYearofBirth.Text = ""
	Me.txtMortgageName = ""
	Me.txtToolsName = ""
	Me.txtPostcode.Text = ""
	Me.txtScore = ""
 
	If Not IsNumeric(Me.txtID) Then
		MsgBox "Please enter only numbers", vbCritical
		Exit Sub
	End If
 
	Dim dbMortgage As New ADODB.Connection
	Dim dbTools As New ADODB.Connection
	Dim rsMortgage As New ADODB.Recordset
	Dim rsTools As New ADODB.Recordset
	Dim myArea As String
 
	dbMortgage.ConnectionString = strMortgage
	dbMortgage.Open
 
	rsMortgage.Source = "SELECT [post code],[telephone],[lastname] from [contacts] WHERE [ID]=" & CLng(Me.txtID)
 
	rsMortgage.Open , dbMortgage, adOpenStatic
 
	If rsMortgage.EOF Then
		MsgBox "Can not find reference number " & Me.txtID, vbCritical
		Exit Sub
	End If
 
	rsMortgage.MoveFirst
	If IsNull(rsMortgage.Fields("Post Code")) Or rsMortgage.Fields("Post code") = "" Then
		MsgBox "There is no post code entered for that record", vbCritical
		Exit Sub
	End If
 
	myArea = Left$(rsMortgage.Fields("Post Code"), 2)
 
	If IsNumeric(Right$(myArea, 1)) Then
		myArea = Left$(myArea, 1)
	End If
 
	dbTools.ConnectionString = strTools
	dbTools.Open
	rsTools.Source = "SELECT [" & myArea & "].* FROM [" & myArea & "] WHERE [telephone]='" & rsMortgage.Fields("Telephone") & "'"
	rsTools.Open , dbTools, adOpenKeyset
 
	If rsTools.EOF Then
		MsgBox "No matching record", vbCritical
		Exit Sub
	End If
 
	Me.txtPostcode.Text = myArea
	Me.txtCameoCode.Text = NZ(rsTools.Fields("Cameo Code").Value)
	Me.TxtCreditBand.Text = NZ(rsTools.Fields("Credit Band").Value)
	Me.txtYearsOfResidency.Text = NZ(rsTools.Fields("Years of residency").Value)
	Me.txtFamily.Text = NZ(rsTools.Fields("Family").Value)
	Me.txtTPS.Text = NZ(rsTools.Fields("tps").Value)
	Me.txtDead.Text = NZ(rsTools.Fields("dead").Value)
	Me.txtYearofBirth.Text = NZ(rsTools.Fields("Year of Birth"))
	Me.txtMortgageName.Text = NZ(rsMortgage.Fields("lastname"))
	Me.txtToolsName.Text = NZ(rsTools.Fields("lastname"))
	Me.btnCount.Enabled = True
	Me.btnCountScore.Enabled = True
	Me.txtScore = NZ(rsTools.Fields("score"))
End Sub


any help will be most appreciated on how i get it to loop.. many thanks

Dave

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Looping


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway