Sub form Help

B

Bill Davis

I have a subform that is in Dataview on my Main form what
i would like to do is when i click on the [product_id] in
the subform is have that product id and infomation be the
current record [product_id] on my main form. Can someone
help we witht he code for this?
Thank you
Bill
 
D

Dirk Goldgar

Bill Davis said:
I have a subform that is in Dataview on my Main form what
i would like to do is when i click on the [product_id] in
the subform is have that product id and infomation be the
current record [product_id] on my main form. Can someone
help we witht he code for this?
Thank you
Bill

So your subform is essentially a datasheet-view list of the same set of
records that are viewed on the main form in single-form view? Try code
like this (warning: air code) for the Click event of the subform's
product_id control:

'----- start of code -----
Private Sub product_id_Click()

If Me.NewRecord Then
Me.Parent!product_id.SetFocus
RunCommand acCmdRecordsGoToNew
Else
Me.Parent.Recordset.FindFirst _
"product_id=" & Me.product_id
End If

End Sub
'----- end of code -----

That assumes that the product_id field is numeric, not text. If it's
text -- but won't contain a single-quote (') character -- use this
condition for the call to FindFirst:

"product_id='" & Me.product_id & "'"
 
G

Guest

Dirk,
THANK YOU THANK YOU VERY MUCH!!
Bill
-----Original Message-----
I have a subform that is in Dataview on my Main form what
i would like to do is when i click on the [product_id] in
the subform is have that product id and infomation be the
current record [product_id] on my main form. Can someone
help we witht he code for this?
Thank you
Bill

So your subform is essentially a datasheet-view list of the same set of
records that are viewed on the main form in single-form view? Try code
like this (warning: air code) for the Click event of the subform's
product_id control:

'----- start of code -----
Private Sub product_id_Click()

If Me.NewRecord Then
Me.Parent!product_id.SetFocus
RunCommand acCmdRecordsGoToNew
Else
Me.Parent.Recordset.FindFirst _
"product_id=" & Me.product_id
End If

End Sub
'----- end of code -----

That assumes that the product_id field is numeric, not text. If it's
text -- but won't contain a single-quote (') character -- use this
condition for the call to FindFirst:

"product_id='" & Me.product_id & "'"

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 

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