467,908 Members | 1,851 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,908 developers. It's quick & easy.

Opening a form and automatically selecting a record

Hello everyone!

Just in case anyone here has experienced this problem and knows how to deal with it:

I have 2 forms from 2 related tables. We have more than 600 records in the first one and of these, 150 also appear in the second table.
We work with the form of the principal table (that is, the one with 600 records). In it, I've got a field that indicates whether the particular record selected is also present in the second table. A sum-up subform is also present, just to get the idea of the data for that record in the second form. Nevertheless, I have also included a command button that launches the second form, just in case some data may be added. My question is the following one: is it possible to launch the second form in a way that the record selected in the first form is the record that appears selected when launched this second form?? That is, if I've got selected (from a list box) the record AAA in the first form and I know it appears in the second one (so I launch it), is it possible that when the second form opens, the record I was working with is already selected??

Best regards!
Apr 18 '08 #1
  • viewed: 1285
Share:
4 Replies
NeoPa
Expert Mod 16PB
Luckily enough, the answer to this doesn't depend on the rest of the explanation :D

When opening a form in VBA code you use the code :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.OpenForm(FormName, _
  2.                     View, _
  3.                     FilterName, _
  4.                     WhereCondition, _
  5.                     DataMode, _
  6.                     WindowMode, _
  7.                     OpenArgs)
The last parameter is what you're interested in. In your situation I expect you'd need the key of the record passed in here.

NB. When referencing Me.OpenArgs in your Form_Open() procedure make sure you do it first thing. This property is cleared when any other code is run. Often saving it to a separate variable for safe-keeping is a good idea.
Apr 23 '08 #2
NeoPa:

Thank you very much for your help. I will proceed as suggested.

Bets regards
Apr 28 '08 #3
NeoPa
Expert Mod 16PB
No worries & Good Luck :)
Apr 28 '08 #4
Thanks NeoPa!!

Bets regards
Apr 30 '08 #5

Post your reply

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

Similar topics

2 posts views Thread by Iain Miller | last post: by
9 posts views Thread by BLUE WATER | last post: by
2 posts views Thread by Lyn | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.