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

I want to set the default value in a field of a form when I migrate from another form

P: 9
I have two forms in my database
1. Product Form
2. Product Extraneous_Details Form

When the user fills the 'Product Form' and clicks on save button then I have build the macro which saves the entry and opens the "Product Extraneous_Details Form".

In the second form the user can choose to product from the drop down menu(derived from the relationship b/w fist and second form tables) and fills in the extra details of the product.

Since I have made user to migrate from "Product Details" to "Product Extra Details Form" I want that the default value in the second form to be the one that he had just entered in the first form.

Though the user can anyways choose the said product form drop down but wouldn't it be great if the default value is already set.

I have created a module in the file and written the following code

Expand|Select|Wrap|Line Numbers
  1. Public intCopyNum As Variant
  3. Function cmdCopy_Click()
  4. intCopyNum = Product_Name
  5. End Function
And in the second form

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Me.Project_Name = intCopyNum
  3. End Sub
I hope the information provided in enough.
Jun 22 '14 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 3,486
I think one of the easiest ways would be to open the second form from the first, and from the first form, set the value of the drop down box you are using on the second form. It would look something like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub GoToForm_Click()
  2.     DoCmd.OpenForm "Product Extraneous_Details"
  3.     Forms![Product Extraneous_Details].[cboProductName] = Me.cboProductName
  4. End Sub
If you have code behind the second forms drop down box that performs any actions to go to the specified action, then you would want to make that sub public and also call that sub from your first form.

Let me know if that hepps.
Jun 22 '14 #2

P: 9
Thanks for the help :)
Jun 22 '14 #3

Post your reply

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