Is this possible?

J

Joao

I want to run a SQL code to present the outcome into a subform:
There's 2 criteria values for user input!

SQLString = "SELECT NrSubscritor, Initiated, Concluded, Year, Month FROM
Processos" & _
" WHERE UserID = " & lngUserNumber & " AND Year= " & intAno & " AND
Month= " & intMes & " AND Despacho=YES ORDER BY TimeStamp DESC;"

funcCorrerSQL SQLString, "E", Me

Public Function funcCorrerSQL(strCmdSQL As String, strParametro As String,
Optional JanelaFP As Form)
Main
'On Error GoTo Erros

Set rstSQL = BD.OpenRecordset( _
strCmdSQL, dbOpenDynaset)

Select Case strParametro
....
Case "E"
subform. ?

End Select

rstSQL.Close
BD.Close

End Function
 
K

Klatuu

You didn't give enought information about what strParametro does.
In any case, you are headed in the wrong direction. instansiating a
recordset then opening a subform will not connect the two in any way.

The correct thing to do is to make the query the record source of the
subform. Where you are using variables to pass parameters to the query, use
form control names in the subform's record source query.
 
J

Joao

strParametro only passes a word string for the case select. Nothing to do
with what I want to accomplish.

How I make the query the record source of the subform? I make a physical
querie?

And how I pass the values?
 
P

Paolo

Hi Joao,

to change the recordsource of your subform just do that

forms!nameoftheform!nameofthesubform.recordsource=sqlstring
forms!nameoftheform!nameofthesubform.requery

HTH Paolo
 
J

Joao

Thanks Paolo but... I get a 2124 Error: "The form name you entered doesn't
follow Processos object naming rules...

The name it's invalid??

Forms!Processos!sfrmListagem.SourceObject = strCmdSQL
Processos=Form
sfrmListagem=Subform
..recordsource doesn't work because isn't a valid method/property
 
P

Paolo

I forgot something, the correct statement is this

Forms!Processos!sfrmListagem.Form.recordSource = strCmdSQL
Forms!Processos!sfrmListagem.Form.requery

I beg your pardon for my mistake
Paolo
 
P

Paolo

I forgot something, the correct statement is this

Forms!Processos!sfrmListagem.Form.recordSource = strCmdSQL
Forms!Processos!sfrmListagem.Form.requery

I beg your pardon for my mistake
Paolo
 
J

Joao

Paolo, RecordSource doesn't work it is not a method, property...
Tried everythin' already....
 
P

Paolo

Well Joao

I can tell you that it works on A2K and A2003. Which version of access are
you using?
Which is the error raised?
The subform sfrmListagem is inserted in the form processos? and the name of
sfrmListagem in the form processos is sfrmListagem?

Regerds Paolo
 
J

Joao

My Access version is 2003
And Yes to all you've wrote.
Trying Forms!Processos!sfrmListagem.Form.recordSource = strCmdSQL get me
a 2467 "The expression you entered refers to an object that is closed or
doesn't exist"

Processos is my FORM where sfrmListagem is my SUBFORM placed on it.
 
P

Paolo

Hi Joao,
well, it could be a reference problem. Verify in the references that are
checked just

Visual Basic for Applications
Microsoft Access 11.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library

If other references are checked uncheck them.
Now try again your app.

Paolo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top