Open a form on double click from a subform

mtagliaferri

Registered User.
Local time
Today, 00:48
Joined
Jul 16, 2006
Messages
550
I all I have looked in the forum but can't find anything that matches I have a form containing a subform called eventswich shows some events in date order, as I have too many information on the table events I could not put them all in the subform if not only the essential information, what I need is if I double click on the field "DATE" it would open the "EVENT" form and show me all the information contained in the record.At the present time I have the filed SELECT RECORD set to NO on the form properties!
Hope I have given a good explanation!!!!
Thanks
Marco
 
In the double-click event of the date field, use the OpenForm Method with the where argument:

DoCmd.OpenForm "formname",,,"SomeField = " & Me.somefield
 
Hi Pat, I think I am missing out something... what is SomeField?
Marco
 
It is the field you use to connect the two tables. I can't tell what its name is based on your description so far so I just used "somefield".
 
Hi Pat, I have put the code on the date properties on the subform, but when I doubleclick on it it opens my main form but it blank fields, what I really need is to open the selected record to view full details, for example on my form I have:
date, hotel, address, email, room n, room rate, smoking, bed type, facilities. On my subform I will have only have date and hotel. what i need is on doubleclicking on the date it will open the record with a specific form showing all the details as address, email, room n etc.
How can I get to this?
Marco
 
Have a look at the attached sample; it is based on the one I previously posted for you.

When you double click the name of the hotel a form will open and display full details.
 

Attachments

Hi ansentry,

I just took a look at your autofill subform...

I am wondering how can you make the subform to automattically add a row when the a hotel is added in?

also, how come you can fill in other fields when you select the hotel without any coding?

cuz I looked at your code and can't find much...

Your help is much appreciatted
 
tdubs said:
Hi ansentry,

I just took a look at your autofill subform...

I am wondering how can you make the subform to automattically add a row when the a hotel is added in?

also, how come you can fill in other fields when you select the hotel without any coding?

cuz I looked at your code and can't find much...

Your help is much appreciatted

Open the sfrmSub in design view .
Now have a look at the record source (qrySub)
Notice that there are 2 tables linked using the keys fkHotelID and HotelID, now have a look at the relationship (point to black line linking the 2 tables and right click) by viewing Join Properties. You will see that the keys must be equal.
So in the combo of the form when I Look up Hotel Windsor (its key is 1) Access stores that in the subs table and also display the data from the hotel table which has the same key (1).
While looking at the query you will see that most of the fields are from the tblHotel and not from the tblSub. In the form you are only "Viewing" the data it is not stored in the tblSub.

Open up the table tblSubs and you will see that only the number for the hotel is stored - not the address etc.

If you want to know all the details about that number you would create a query and add the 2 tables (tblSub & tblHotels) to it. Put all the fields in and then have a look you will see how it works ( I hope)
 

Users who are viewing this thread

Back
Top Bottom