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

Opening a form and automatically selecting a record

P: 66
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
Share this Question
Share on Google+
4 Replies


NeoPa
Expert Mod 15k+
P: 31,186
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

P: 66
NeoPa:

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

Bets regards
Apr 28 '08 #3

NeoPa
Expert Mod 15k+
P: 31,186
No worries & Good Luck :)
Apr 28 '08 #4

P: 66
Thanks NeoPa!!

Bets regards
Apr 30 '08 #5

Post your reply

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