Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need code for connections

Status
Not open for further replies.

ADMOODY

Programmer
Mar 21, 2002
3
US
Good afternoon,

I'm currently new to using Access and VBA. I'm trying to create a form that will include a selecting a month (combo box) to activate my query. I have the SQL statement and the months but I'm having problems getting the connections with the 'Report_Open click statement'. Here is what I have so far:

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String

strSql = ""
strSql = strSql & "SELECT dbo_Client.ClientName, dbo_BusinessType.Description, Count(dbo_Client.ClientName) AS [Count]"
strSql = strSql & "FROM (((dbo_Client INNER JOIN dbo_ClientIndicators ON dbo_Client.NationalClientIndicator = dbo_ClientIndicators.NationalClientIndicator) INNER JOIN dbo_OrderRecord ON dbo_Client.ClientID = dbo_OrderRecord.ClientID) INNER JOIN dbo_Product ON dbo_OrderRecord.ProductID = dbo_Product.ProductID) INNER JOIN dbo_BusinessType ON dbo_Product.BusinessType = dbo_BusinessType.BusinessType "
strSql = strSql & "WHERE dbo_OrderRecord.Created between " & Month(Date) - 1 & "/1/" & Year(Date) & " and " & Month(Date) & "/1/" & Year(Date) & " AND dbo_Client.NationalClientIndicator='p' "
strSql = strSql & " GROUP BY dbo_Client.ClientName, dbo_BusinessType.Description;"


Set db = CurrentDb
Set rs = db.OpenRecordset(strSql)
Me.frmClient.Form.Recordset = rs

Please Help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top