Subform help please

T

TotallyConfused

I have main form and subform. In my subform, I want to call another form for
data entry when I click on one of the fields in the subform. It is working
fine by bringing up the form but with no data. Can someone please help me
why I am not getting any data? This is the event I have on the form that is
beign called from the subform's field.

Private Sub Field_ID_Click()
DoCmd.OpenForm "frm_myform", , , , OpenArgs:="[Field ID]='" & Me![Field
ID] & "'"
End Sub

Thank you.
 
D

Damon Heron

Why not use the where argument instead of OpenArgs?

DoCmd.openform "frm_myform", , , "[FieldID] = " & Me.[FieldID]

Damon
 
T

TotallyConfused

Thank you for responding. I have changed to "where argument". However, how
do I write to include to more fields that need to be added so that when my
form opens it points to the correct one. Can more fields be added to this?
How?

Damon Heron said:
Why not use the where argument instead of OpenArgs?

DoCmd.openform "frm_myform", , , "[FieldID] = " & Me.[FieldID]

Damon

TotallyConfused said:
I have main form and subform. In my subform, I want to call another form
for
data entry when I click on one of the fields in the subform. It is
working
fine by bringing up the form but with no data. Can someone please help me
why I am not getting any data? This is the event I have on the form that
is
beign called from the subform's field.

Private Sub Field_ID_Click()
DoCmd.OpenForm "frm_myform", , , , OpenArgs:="[Field ID]='" &
Me![Field
ID] & "'"
End Sub

Thank you.
 
D

Damon Heron

Now Im TotallyConfused. You are calling a form that is bound to a table
that has
a fieldID. There should be only one record that has that distinct fieldID.
If not, then you must have a form that has a fieldID that is not the primary
key? You can use AND to add parameters to your search.
"FieldID= " & me.fieldID " AND otherID = " & me.otherID


I have found it is good practice to separate out your criteria, like this:
Dim stDocName As String
Dim stLinkCriteria As String
stLinkCriteria = "CustomerID = "& Me!CustomerID
stDocName = "frmCustomerHistory"
'You can also add an openargs to the same formopen
event.
DoCmd.openform stDocName, , , stLinkCriteria, , ,"someOpenArgument"


TotallyConfused said:
Thank you for responding. I have changed to "where argument". However,
how
do I write to include to more fields that need to be added so that when my
form opens it points to the correct one. Can more fields be added to
this?
How?

Damon Heron said:
Why not use the where argument instead of OpenArgs?

DoCmd.openform "frm_myform", , , "[FieldID] = " & Me.[FieldID]

Damon

TotallyConfused said:
I have main form and subform. In my subform, I want to call another
form
for
data entry when I click on one of the fields in the subform. It is
working
fine by bringing up the form but with no data. Can someone please help
me
why I am not getting any data? This is the event I have on the form
that
is
beign called from the subform's field.

Private Sub Field_ID_Click()
DoCmd.OpenForm "frm_myform", , , , OpenArgs:="[Field ID]='" &
Me![Field
ID] & "'"
End Sub

Thank you.
 

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