Opening a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to build a search window. I have it working to retrieve search
result records in a subform called Vendor_Search_Results. I am trying to
find a way to allow the user to double-click on a record in the search
results subform to navigate to the corresponding record displayed in
frm_Vendor for editing.

Can anyone help me with this? I don't know a lot of VB so specific code (as
much as possible, that is) would be really helpful along with where to place
it.

Thanks!
 
Lori said:
I am trying to build a search window. I have it working to retrieve search
result records in a subform called Vendor_Search_Results. I am trying to
find a way to allow the user to double-click on a record in the search
results subform to navigate to the corresponding record displayed in
frm_Vendor for editing.

Can anyone help me with this? I don't know a lot of VB so specific code (as
much as possible, that is) would be really helpful along with where to place
it.


There's a command button wizard that should do that for you.
The key is to use the OpenForm method's WhereCondition
argument. E.g.

DoCmd.OpenForm "frm_Vendor, _
WhereCondition:= "keyfield = " & Me.keyfield
 
Within my subform's properties, one one of my field's (TIN_Nbr) I put the
following on the double-click event:

Private Sub TIN_Nbr_DblClick(Cancel As Integer)
DoCmd.OpenForm "frm_Vendor"
where frm.Vendor.TIN_Nbr = Me!TIN.Nbr
End Sub

I receive and error though stating the function or sub is not defined. What
do I need to do? I'm not sure where I would use a command button like you
suggested as I have rows of records that match my search criteria and I'd
like the user to be able to double-click on a record to open the vendor form
for that record.

Thanks!
 
That's a rather free translation of what I said ;-)

I think this is more precise:

DoCmd.OpenForm "frm_Vendor", _
WhereCondition:= "TIN_Nbr =" & Me!TIN.Nbr
 
Whoops! :-) Thanks for the clarification. I'm not sure you are going to
be able to help me with this but I put in the code the right way and now I am
getting an error that says that database can't find the field "TIN" referred
to in my expression. (Runtime error 2465).

I have double-checked both the subform and my Vendor Form and the field is
named TIN_Nbr - just like I have it in the code you provided. Any ideas?
Thanks so much for your help Marsh!

Marshall Barton said:
That's a rather free translation of what I said ;-)

I think this is more precise:

DoCmd.OpenForm "frm_Vendor", _
WhereCondition:= "TIN_Nbr =" & Me!TIN.Nbr
--
Marsh
MVP [MS Access]

Within my subform's properties, one one of my field's (TIN_Nbr) I put the
following on the double-click event:

Private Sub TIN_Nbr_DblClick(Cancel As Integer)
DoCmd.OpenForm "frm_Vendor"
where frm.Vendor.TIN_Nbr = Me!TIN.Nbr
End Sub

I receive and error though stating the function or sub is not defined. What
do I need to do? I'm not sure where I would use a command button like you
suggested as I have rows of records that match my search criteria and I'd
like the user to be able to double-click on a record to open the vendor form
for that record.
 
Please disregard my last post - I figured it out - the end of the code had
TIN.Nbr instead of TIN_Nbr. Thanks so much for helping me!!!

Marshall Barton said:
That's a rather free translation of what I said ;-)

I think this is more precise:

DoCmd.OpenForm "frm_Vendor", _
WhereCondition:= "TIN_Nbr =" & Me!TIN.Nbr
--
Marsh
MVP [MS Access]

Within my subform's properties, one one of my field's (TIN_Nbr) I put the
following on the double-click event:

Private Sub TIN_Nbr_DblClick(Cancel As Integer)
DoCmd.OpenForm "frm_Vendor"
where frm.Vendor.TIN_Nbr = Me!TIN.Nbr
End Sub

I receive and error though stating the function or sub is not defined. What
do I need to do? I'm not sure where I would use a command button like you
suggested as I have rows of records that match my search criteria and I'd
like the user to be able to double-click on a record to open the vendor form
for that record.
 
Back
Top