By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,392 Members | 1,525 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,392 IT Pros & Developers. It's quick & easy.

Link records in different forms

P: 15
I am very new at this and find myself lost in the numerous possibilities Acces has to offer, some help with the folowing problem would be very nice.

I have created 2 forms, named 'Contact List' and 'Contact Details'. The form Contact List, has a subform with a table: 'Contact subform', which displays all the contacts in a table. I also created a button (in the subform) to go from the list to the details, now I would like to go to the record that is selected in the subform's table.

Thank you!
Kind regards,

Philippe
Aug 7 '08 #1
Share this Question
Share on Google+
10 Replies


NeoPa
Expert Mod 15k+
P: 31,661
Are you trying to go to the specific record within the full list? Or would filtering the [Contact Details] form be more appropriate? That way ONLY the relevant record would be opened in the form.
Aug 7 '08 #2

P: 15
That is a good question. It would give more possibilities if the user still has the possibility to navigate between the records after the specific record is opened. So I guess that makes it more difficult to work through a filter. I was thinking more in the direction of introducing a 'go to record' action with appropriate conditions, but which I would not know how to define. Is this a possibility?

Thank you!

Philippe
Aug 7 '08 #3

NeoPa
Expert Mod 15k+
P: 31,661
I think so Philippe.

However, allowing that extra operator flexibility may well prove a problem. If the operator always navigates via your main form the situation will be more predictable, which will probably make the project more stable.

But let me know if you still want the ability to navigate between records on a form, and also if this will need to be invoked remotely (as in from the OTHER form).
Aug 7 '08 #4

P: 15
I guess you are right and that I could reduce navigating possibilities to the main form. So when 'Contact Details' are asked for the selected record, they show up as a 'pop up' which can easily be closed again.

Could you help me with the filter settings though? Should I use a macro to solve this problem?

Thank you!


I think so Philippe.

However, allowing that extra operator flexibility may well prove a problem. If the operator always navigates via your main form the situation will be more predictable, which will probably make the project more stable.

But let me know if you still want the ability to navigate between records on a form, and also if this will need to be invoked remotely (as in from the OTHER form).
Aug 7 '08 #5

NeoPa
Expert Mod 15k+
P: 31,661
I can help - and lead, but I can't do it for you.

Get it started and let me know what you can do and where you get stuck.

If I'm to help though, you will probably need to be more clear and precise in your communications. This isn't just you - this applies to most people. Trouble is, working via a web page is a lot lot harder than working on a database you can see, so I need all the clues you can give me to understand where you are.
Aug 7 '08 #6

P: 15
Dear NeoPa,

If you could get me started, it would be of great help.
I will try to explain - the best I can - what I am trying to do:

I have a main form (Contact List) with a subform (Contacts subform). This subform has a table in it displaying the fields (ID, Company, Last Name, First Name) of my table. The ID is basicily an autonumber for each record.

Now I would like to create a link between the main form and another form (Contact Details). When the user clicks on the ID of a record in the subform (example: number 5) the Contact Details form should open on this same record (5).
Basicily, when clicked on a contact, the contact details should 'pop up'.

Is this possible? I have searched the internet and forums for a similiar case, without any results. How should I get started?

Should I write a macro with an open form action, folowed by an apply filter action? I have tried this but got stuck defining the filter.

Thank you in advance!
Kind regards,

Philippe
Aug 8 '08 #7

100+
P: 167
Hi P.

I would use double click on ID in subform to open a pop-up in order to avoid unintentional openings.
In double click event of ID field in subform you could put a code doing this:
Expand|Select|Wrap|Line Numbers
  1. Store the value of current ID in a variable
  2. Open a pop-up form with details
  3. Move focus to ID field on pop-up form
  4. Docmd.FindFirst .....(find a value stored in a variable)
Aug 8 '08 #8

NeoPa
Expert Mod 15k+
P: 31,661
Firstly, H makes a good point about using Double-Click to trigger the code.

Next, you start by designing a form (Contact Details) to display the data from the table you need to display. The design of the form will be unrestricted and will show (when not filtered) all records in the table.

This form should have the .PopUp property set to True if you want it as a Pop-Up.

In the Double-Click event procedure for your control where [ID] is shown, have something like :
Expand|Select|Wrap|Line Numbers
  1. Private Sub ID_DoubleClick()
  2.   Dim strFilter As String
  3.  
  4.   strFilter = Replace("[ID]=", "%I", Me.ID)
  5.   Call DoCmd.OpenForm(FormName:="[Contact Details]", WhereCondition:=strFilter)
  6. End Sub
Aug 8 '08 #9

P: 15
Thank you for your help!

I tried your code, it opens the contact details form, but not on the right record (where I double clicked on)

I tried almost anything, but no results so far.
This is my final code, could you take a look at it please?

Expand|Select|Wrap|Line Numbers
  1. Private Sub ID_DblClick(Cancel As Integer)
  2.  
  3.     Dim strFilter As String
  4.     Dim lngrecordnum As Long
  5.  
  6.     lngrecordnum = frm.CurrentRecord
  7.  
  8.     strFilter = Replace("[ID]=", "%I", lngrecordnum)
  9.  
  10.     Call DoCmd.OpenForm("Contact Details", acNormal, strFilter)
  11.  
  12. End Sub
Thanks!
Aug 8 '08 #10

NeoPa
Expert Mod 15k+
P: 31,661
I had an error in the code I posted - but you also didn't copy it properly.

Try with this :
Expand|Select|Wrap|Line Numbers
  1. Private Sub ID_DoubleClick()
  2.   Dim strFilter As String
  3.  
  4.   strFilter = Replace("[ID]=%I", "%I", Me.ID)
  5.   Call DoCmd.OpenForm(FormName:="[Contact Details]", WhereCondition:=strFilter)
  6. End Sub
Aug 8 '08 #11

Post your reply

Sign in to post your reply or Sign up for a free account.