Query in VBA

neerajav

New member
Local time
Yesterday, 20:17
Joined
Jul 9, 2004
Messages
5
I have an Access report and all fields are populated from a query in the report except 1 field which needs to be evaluated from a separate function that needs to be coded in VBA. How do I write the query? It is nothing but a select statement like: "select * from table A where <condition>"
how do I execute this? WHat references do I need to add????

I have a code like :
Dim RetQuery As String
Dim qReturns As Integer
RetQuery = "select count(*) into :ll_cursor_count from <table> where
ownership_type ='Jobber Served';"
qReturns = Application.sql(RetQuery, retValue)

But what happens is I dont get prompted for 'sql' when I hit the '.' after 'application' in the sentence qReturns = Application.sql(RetQuery, retValue)
what kinda instance do I have to create? what reference do i have to add?
or can u suggest any alternate way of doing this?????




Iam new to Access and VB and any help will be much appreciated.
 
Dim rst As New ADODB.Recordset
Dim rstSQL As String


rstSQL = "Select * from tblsource" ' Put whatever SQL you want here

rst.Open rstSQL, CurrentProject.Connection, adOpenDynamic, adLockPessimistic
 
neerajav,

Code:
Me.SomeControl = DCount("[SomeField]", "SomeTable", "[ownership_type]  = 'Jobber Served'")

Wayne
 

Users who are viewing this thread

Back
Top Bottom