Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 22070

Control DB with 2 SQL statements

$
0
0
Hi
I am re-writing an old VB program called Address Book which
of course contains Names & Addresses,Phone Numbers, E Mail Addresses etc
In my original project all data was kept on 1 Access DB but as I have now
extended the telephone numbers to include all EU codes I decided to put
all this information on a new DB called Numbers so that the original DB
columns did not require modification. All code works without errors but
not as I had intended. Now to the point of my post:-
In my original DB I used this code to stop Addressee's without telephone numbers
from being printed.
Code:

VB6
With frmTopMain
 strQuery = "SELECT * FROM Home WHERE" _
  & " HPhone IS NOT NULL Or" _
  & " MPhone IS NOT NULL Or" _
  & " OPhone NOT NULL Or" _
  & " WPhone IS NOT NULL" _
  & " ORDER BY LastName,FirstName"
    .adoPhone.RecordSource = strQuery
    .adoPhone.Refresh
End With

With the added DB I changed my code to:-
Code:

VB6
With frmTopMain
    strQuery = vbNullString
    strQuery = "SELECT * FROM Home WHERE" _
      & " Nums_One IS NOT NULL" _
      & " ORDER BY S_Name,F_Name"
    .adoPhone.RecordSource = strQuery
    .adoPhone.Refresh
  Set .dgControl.DataSource = .adoControl
Plus for other DB
  With frmTopMain
    strQuery = vbNullString
    strQuery = "SELECT * FROM Numbers ORDER BY S_Name"
    .adoPhone.RecordSource = strQuery
    .adoPhone.Refresh
  Set .dgPhone.DataSource = .adoPhone

With this setup I get a matching DB problem that I do not want
when I run the Telephone Browser Form
because I cannot now start at the first record
as the first record does not have a telephone number listed
I finish with Names from record 1 and phone numbers from
record 2
I cannot find a way to make dgControl stay sync with dgPhone
is there a better way to do this?

Viewing all articles
Browse latest Browse all 22070


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>