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 / Forms Programming / July 2007

Tip: Looking for answers? Try searching our database.

Passing a value to a query in a subform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dan Neely - 25 Jul 2007 19:25 GMT
I have a form with a query that requires a value to be provided for a
WHERE clause.  I can open the form on it's own and enter the desired
value into a popup dialog without problem.  But if I drag that form
onto a second instead of getting a popup to enter the value access03
crashes.

How can I prevent the crash from happening and pass the value for the
query from the main form automatically.
Dan Neely - 25 Jul 2007 21:18 GMT
> I have a form with a query that requires a value to be provided for a
> WHERE clause.  I can open the form on it's own and enter the desired
[quoted text clipped - 4 lines]
> How can I prevent the crash from happening and pass the value for the
> query from the main form automatically.

I've managed to work around this by making the child form unbound and
running query in the parents OnCurrent event to generate a record set,
but would still like to know if there's a way to do this on a bound
form.
Harry - 26 Jul 2007 08:38 GMT
Hi Dan,

For me it is not the best solution to alter the query at OnCurrent event.
Because this procedure is triggered every time an action is performed,
including actions not in relation to your subform.

What I have done is indeed create an unbound child form and alter the query
while doing some action (like pressing a form button, combobox whatever) the
recordsourde for the subform changes and the new data is displayed.

what you could do fe.

create on the master form a textbox named TAGID
 within the code
Option Compare Database
Dim sSQL, sSQLField, stDocname As String

Private Sub BtnPC1_Click()
Me.TAGID = Me.BtnPC1.TAG
QCONTENTPC
End Sub

Function QCONTENTPC()
sSQLField = "(((Software." & TAGID & ") = Yes))"
sSQL = " SELECT Software.*, Disc.DiscName" & _
      " FROM Software" & _
      " INNER JOIN Disc ON Software.DiscID = Disc.DiscID" & _
      " WHERE" & sSQLField & _
      " ORDER BY Software.ProgramName;"
   CurrentDb.QueryDefs("Q-ContentPC").SQL = sSQL
Me.PC_Content_subform.Form.RecordSource = sSQL
end function.

To use this for a bound form is more or less equal.
first you need to open the form, and secondly you can define the
recordsource for that form.
fe:
DoCmd.OpenForm "BoundForm"
Forms!BoundForm!.Form.RecordSource = sSQL

good luck
Harry

> > I have a form with a query that requires a value to be provided for a
> > WHERE clause.  I can open the form on it's own and enter the desired
[quoted text clipped - 9 lines]
> but would still like to know if there's a way to do this on a bound
> form.
 
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.