Calling record from a subform

  • Thread starter Thread starter Antonio
  • Start date Start date
A

Antonio

Hello, all...this is driving me insane!!!
I have a form, which contains a subform with a list of
unresolved issues (only the company name, contact, and
phone). What I am trying to do is this: when a user
double-clicks on the companyname field, the Trouble
Tickets form opens and displays that customer's record.
What it's happening is that it opens the Trouble Tickets
form, but it displays the first record, not the one I
double-click on. Hope this is clear...here is the code
for the subform's control:

Private Sub CompanyName_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmTroubleTicket", , _
wherecondition:="CompanyName = """ & Me!CompanyName
& """"

DoCmd.Close acForm, "OpenTTs"
end sub
 
-----Original Message-----
Hello, all...this is driving me insane!!!
I have a form, which contains a subform with a list of
unresolved issues (only the company name, contact, and
phone). What I am trying to do is this: when a user
double-clicks on the companyname field, the Trouble
Tickets form opens and displays that customer's record.
What it's happening is that it opens the Trouble Tickets
form, but it displays the first record, not the one I
double-click on. Hope this is clear...here is the code
for the subform's control:

Private Sub CompanyName_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmTroubleTicket", , _
wherecondition:="CompanyName = """ & Me!CompanyName
& """"

DoCmd.Close acForm, "OpenTTs"
end sub
.
Hi Antonio,

Just so that I am clear about this...
in the field list - company name, contact, and
phone - which field links with the record that you want to
go to when frmTroubleTicket form opens?

Merry Christmas
Jonathan
 
DoCmd.OpenForm "frmTroubleTicket", , _
wherecondition:="CompanyName = """ & Me!CompanyName
& """"


Try:
DoCmd.OpenForm "frmTroubeTicket",,,"CompanyName = '" & me!CompanyName & "'"

Also, you should use something like "id" just in case the company name is
not entered, or perhaps you have more then one entry with the same company
name. Using a key id here is usually much better. If the sub-forms records
has an "id" field (say, a autonumber field), then you can use:

DoCmd.OpenForm "frmTroubeTicket",,,"id = '" & me!id

Note that id does not have to be placed on the form, but it certainly has to
be in the query/table that the sub-form record source is based on.
 
Jonathan, I have a TicketID, CompanyName, DateCreated
fields. I guess the best way would be to open the form
via TicketID, since there may be more than one ticket for
the same company. This subform feeds from
tblTroubleTickets, which is the same table from which the
frmTroubleTickets feeds from. Antonio
 
-----Original Message-----
Jonathan, I have a TicketID, CompanyName, DateCreated
fields. I guess the best way would be to open the form
via TicketID, since there may be more than one ticket for
the same company. This subform feeds from
tblTroubleTickets, which is the same table from which the
frmTroubleTickets feeds from. Antonio

Antonio, your guess seems to be the best solution :-)

Luck
Jonathan
 
Back
Top