MySQL=$"
SELECT distinct PS.ID, u.UserID ,FacilityID,pl.ProviderID,pl.ClientID,pl.ID as PlacementLocalID,
pl.MatchupID,ps.JobDate,Shift,cl.FullName ,start,OriginalStart,OriginalFinish,
pa.PAID,PA.Restrictions,cl.Distance,ScheduleMonitoring,u.UserName,U.Password,ProviderTypeID,RegKey,PA.PayeeID
FROM tblUsers as U
INNER JOIN tblMobileUserAccounts as MA on u.UserID=ma.UserID
inner JOIN tblPlacement as PL on ma.ProviderID=pl.ProviderID
inner JOIN tblPlacementSchedule as PS on pl.id=ps.PlacementLocalID
INNER JOIN tblClients as CL on Cl.ClientID=pl.ClientID
INNER JOIN tblPriorAuthorization as PA on pa.PAID=ps.PAID
where start is not null
and Finish is null
And julianday(date('now','localtime'))-julianday(Date(substr(ps.JobDate, 7,4) || '-' || substr(ps.JobDate, 1,2) || '-' || substr(ps.JobDate, 4,2)))<=7;
"$
rs=Main.SQL1.ExecQuery(MySQL)
Do While rs.NextRow
Main.SelectedClientAddress=rs.GetString("Address")
Loop
rs.close