Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / May 2008

Tip: Looking for answers? Try searching our database.

Displaying data in a subform via Recordset...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joao - 29 May 2008 14:15 GMT
Trying to pass a SQL expression to a subform. The SQL expression returns
records using Query view in access, but using this...
...
SQLString = "SELECT * FROM Processos"
          funcRunSQL SQLString
...

Public Function funcRunSQL(strCmdSQL As String)

Set BD = CurrentDb

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

'Name of the subform
subfrmConcDU.Form.RecordSource = strCmdSQL

rstSQL.Close
           BD.Close

I get nothing! Why?
Klatuu - 29 May 2008 15:25 GMT
Opening a recordset is not necessary.  All you need is:

   Me.subfrmConcDU.Form.RecordSource = "SELECT * FROM Processos;"

Signature

Dave Hargis, Microsoft Access MVP

> Trying to pass a SQL expression to a subform. The SQL expression returns
> records using Query view in access, but using this...
[quoted text clipped - 17 lines]
>
> I get nothing! Why?
Joao - 29 May 2008 16:13 GMT
Thank you Klatuu, but I get no records whatsoever. Maybe something in subform
that's not right?

> Opening a recordset is not necessary.  All you need is:
>
[quoted text clipped - 21 lines]
> >
> > I get nothing! Why?
Klatuu - 29 May 2008 16:17 GMT
How are the form and subform related?
In other words, do you have the Link Master Field(s) and Link Child Field(s)
properties of the subform control set to fields in you form's record source
and subform's recordsource set properly?
Signature

Dave Hargis, Microsoft Access MVP

> Thank you Klatuu, but I get no records whatsoever. Maybe something in subform
> that's not right?
[quoted text clipped - 24 lines]
> > >
> > > I get nothing! Why?
Joao - 29 May 2008 16:39 GMT
No... is because of that? I think I've tried it too but to no avail...

> How are the form and subform related?
> In other words, do you have the Link Master Field(s) and Link Child Field(s)
[quoted text clipped - 29 lines]
> > > >
> > > > I get nothing! Why?
Klatuu - 29 May 2008 16:43 GMT
How is the form's recordset related to the subform's recordset?

Try pasting your SQL into a query in the query designer in SQL view and see
what it returns.
Signature

Dave Hargis, Microsoft Access MVP

> No... is because of that? I think I've tried it too but to no avail...
>
[quoted text clipped - 31 lines]
> > > > >
> > > > > I get nothing! Why?
Joao - 29 May 2008 16:52 GMT
I get records, but when I use the code below it returns none.

> How is the form's recordset related to the subform's recordset?
>
[quoted text clipped - 36 lines]
> > > > > >
> > > > > > I get nothing! Why?
Klatuu - 29 May 2008 17:01 GMT
Okay that anwered one of my questions.
Now, in the subform control on the main form there are two properties, Link
Master Field(s) and Link Child Field(s)
These are used to relate the child records in the subform to the parent
record in the main form.  The Link Master Field(s) property should have the
name of the field or fields you use in the main form's recordset to relate to
records in the subform's recordset.  The Link Child Field(s) property should
have the name of the field or fields in the subform's recordset you use to
relate to the record in the main form.  If these are not set correctly, you
may not get any records in the subform.

Signature

Dave Hargis, Microsoft Access MVP

> I get records, but when I use the code below it returns none.
>
[quoted text clipped - 38 lines]
> > > > > > >
> > > > > > > I get nothing! Why?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.