al4629740
asked on
Combine sql queries so that they show up on the vb6 datagrid
How can I combine these two sql queries so that they both show up on the datagrid in vb6? I want the first query to be combined with the bottom code.
esql = "select H.Agency,H.RegID,R.LastName,R.FirstName, H.ActivityID,A.ActivityName,H.Narrative, H.ActivityDate, H.Program, H.Hours, ltrim(right(convert(varchar(25), H.HourTimeFrom, 100), 7)) as 'Time From', " & _
"ltrim(right(convert(varchar(25), H.HourTimeTo, 100), 7)) as 'Time To', H.SubGroup,H.Area, H.ParticipantHour, H.VolunteerHour, H.Fiscal, H.EntryTime " & _
"from tblOrgHours H " & _
"JOIN tblOrgRegistrations R on H.RegID = R.RegID " & _
"JOIN tblOrgActivities A on H.ActivityID = A.ActivityID " & _
"Where H.AgencyID = '" & AgencyID & "' And H.ActivityDate >= '" & DTPicker1 & "' And H.ActivityDate <= '" & DTPicker2 & "'" & " " & String1 & " order by r.LastName,r.FirstName, H.Program, A.ActivityName, H.ActivityDate,H.HourTimeFrom"
esql = "select AgencyID from tblOrgProfile where [System Name] ='" & Combo1 & "'"
If rec.State = adStateOpen Then
rec.Close
End If
rec.CursorType = adOpenStatic
rec.CursorLocation = adUseClient
rec.LockType = adLockOptimistic
rec.Open esql, conn, , , adCmdText
Text1 = rec.RecordCount
If rec.EOF And rec.BOF Then
Set DataGrid1.DataSource = Nothing
MsgBox "There are no Records for this Query. ", vbOKOnly, "No Data Found"
Exit Sub
End If
Set DataGrid1.DataSource = rec
rec.MoveFirst
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
With a union query, you can use explicit null columns in the case queries don't have the same number of columns:
SELECT Col1, Col2, Col3
FROM MyFirstTable
UNION ALL
SELECT Col1, Null, Null
FROM MySecondTable;
ASKER
Would it be possible for someone to demonstrate using the columns and table structure that I sent. I took time to post those for that reason.
Thanks
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER