DoCmd.openform

G

Guest

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]
 
G

Guest

I tried both of these and each still asks for a parameter value. I also
tried removing the . in front of the Form! and that didnt help either. Does
it matter that the on click event is comming from a subform. Is there
anything else you can think of?

DoCmd.OpenForm "Entry Form",,,"[Entry
Form]![ID]=Forms![Transactions]![Transaction Details Subform].Form![ID]

and

DoCmd.OpenForm "Entry Form",,,"[Entry
Form]![ID]=Forms![Transactions].Form![Transaction Details Subform]![ID]


Ofer Cohen said:
Try adding the word "Form" to the path

DoCmd.OpenForm "Entry Form",,,"[Entry
Form]![ID]=Forms![Transactions]![Transaction Details Subform].Form![ID]
--
Good Luck
BS"D


Ryan said:
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]
 
G

Guest

First check if the names of the forms and fields are spelled properly

Forms![Main Form Name]![Sub Form control name in the main form].Form![Field
Name]

Open the Immidiate window (press ctrl + g) and write the full path, with a
question mark before and press enter, check which value is returned.
The form need to be open
If the path is wrong you'll get an error message

?Forms![Transactions]![Transaction Details Subform].Form![ID]


--
Good Luck
BS"D


Ryan said:
I tried both of these and each still asks for a parameter value. I also
tried removing the . in front of the Form! and that didnt help either. Does
it matter that the on click event is comming from a subform. Is there
anything else you can think of?

DoCmd.OpenForm "Entry Form",,,"[Entry
Form]![ID]=Forms![Transactions]![Transaction Details Subform].Form![ID]

and

DoCmd.OpenForm "Entry Form",,,"[Entry
Form]![ID]=Forms![Transactions].Form![Transaction Details Subform]![ID]


Ofer Cohen said:
Try adding the word "Form" to the path

DoCmd.OpenForm "Entry Form",,,"[Entry
Form]![ID]=Forms![Transactions]![Transaction Details Subform].Form![ID]
--
Good Luck
BS"D


Ryan said:
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]
 
A

Allen Browne

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
 

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