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 / March 2007

Tip: Looking for answers? Try searching our database.

DoCmd.openform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ryan - 08 Mar 2007 20:17 GMT
I have a form called [Transactions] that has a subform [Transaction Details
Subform].  I would like a form called [Entry Form] to open when I click on
the [ID] field of the [Transacion Deatails Subform].  Here is the code I have
so far, but when I run the code it ask's me for parameter values for the
Entry Form!ID and the Transactions!Transaction Details Subform!ID fields.  Do
I have my code wrong?

DoCmd.OpenForm "Entry Form",,,"[Entry
Form]![ID]=Forms![Transactions]![Transaction Details Subform]![ID]
Allen Browne - 09 Mar 2007 02:06 GMT
The WhereCondition string needs to consist of the field name on the target
form, and a value concatenated into the string.

Something like this:

Dim strWhere As String
strWhere = "[ID] = " & Nz(Forms![Transactions]![Transaction Details
Subform].Form![ID],0)
'Debug.Print strWhere
DoCmd.OpenForm "Entry Form",,, strWhere

For an explanation of the ".Form" bit, see:
   http://allenbrowne.com/casu-04.html

The Nz() avoids an error if ID is null (e.g. at a new record.)

If the ID is a Text field (not a Number field), you need extra quotes:
   http://allenbrowne.com/casu-17.html

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I have a form called [Transactions] that has a subform [Transaction Details
> Subform].  I would like a form called [Entry Form] to open when I click on
[quoted text clipped - 7 lines]
> DoCmd.OpenForm "Entry Form",,,"[Entry
> Form]![ID]=Forms![Transactions]![Transaction Details Subform]![ID]
 
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.