parent form needs to move to selected child record

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

Guest

I have a single form that shows each time a client contacts the agency. I
have a datasheet subform that lists all the contacts by date. I would like
for the user to be able to double click on a contact date in the datasheet
subform & have the parent single form move to that particular contact date.
Right now I can get it to open a new version of the single contact form
(leaving the parent & subform in the background), but I really want the
parent contact form to just "move" to the record selected in the child form.
Can this be done?
 
Donna said:
I have a single form that shows each time a client contacts the
agency. I have a datasheet subform that lists all the contacts by
date. I would like for the user to be able to double click on a
contact date in the datasheet subform & have the parent single form
move to that particular contact date. Right now I can get it to open
a new version of the single contact form (leaving the parent &
subform in the background), but I really want the parent contact form
to just "move" to the record selected in the child form. Can this be
done?

Something like the following code in the DblClick event of the
ContactDate control on the subform should do it, I think:

'----- WARNING: AIR CODE -----
Private Sub ContactDate_DblClick(Cancel As Integer)

Me.Parent.Recordset.FindFirst "ContactDate=" & _
Format(Me.ContactDate, "\#mm/dd/yyyy\#"

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

Of course, you have to use your names for the field and control -- I've
used "ContactDate" for both.
 
I get the error message "The Microsoft Jet Database Engine does not recognize
'Date' as a valid field name or expression."
 
Donna said:
I get the error message "The Microsoft Jet Database Engine does not
recognize 'Date' as a valid field name or expression."

Does your field name contain spaces, by any chance? If it does, you
must enclose it in square brackets ([]). For example,

Me.Parent.Recordset.FindFirst "[Contact Date]=" & _
Format(Me.[Contact Date], "\#mm/dd/yyyy\#"
 
I had thought of that too & tried it that way, but it doesn't work. The name
of the field is "Date". I thought it might not be working because DATE might
be a reserved word so I tried it with other fields too ,but I keep getting
the same error message, other than it says it can't find whatever other field
name I put in there.

Dirk Goldgar said:
Donna said:
I get the error message "The Microsoft Jet Database Engine does not
recognize 'Date' as a valid field name or expression."

Does your field name contain spaces, by any chance? If it does, you
must enclose it in square brackets ([]). For example,

Me.Parent.Recordset.FindFirst "[Contact Date]=" & _
Format(Me.[Contact Date], "\#mm/dd/yyyy\#"

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

(please reply to the newsgroup)
 
Donna said:
I had thought of that too & tried it that way, but it doesn't work.
The name of the field is "Date". I thought it might not be working
because DATE might be a reserved word so I tried it with other fields
too ,but I keep getting the same error message, other than it says it
can't find whatever other field name I put in there.

You're right, "Date" is a bad choice of a name for a field or control,
and could be causing problems. Your attempts with other fields may have
failed just because you didn't get the field and control names right.

What is the recordsource of the parent form? If a query, please post
both the name and the SQL of the query.

What is the name of the control on the subform that contains the contact
date?
 
I am so EMBARRASSED! When you said check the SQL, I started reading it &
realized that the child form is not a child to what I thought was the Parent;
it's a child to the form sitting behind the one I thought was the parent. So
now I have the correct form name being referred to & it works fine. Thanks
for your help; I'm sorry I wasted so much of your time. I will try to
remember to look at the SQL format before doing this again.
 
Donna said:
I am so EMBARRASSED! When you said check the SQL, I started reading
it & realized that the child form is not a child to what I thought
was the Parent; it's a child to the form sitting behind the one I
thought was the parent. So now I have the correct form name being
referred to & it works fine. Thanks for your help; I'm sorry I
wasted so much of your time. I will try to remember to look at the
SQL format before doing this again.

No problem; I'm glad to help.
 
Back
Top