Passing value from one form to another

benkingery

Registered User.
Local time
Today, 07:52
Joined
Jul 15, 2008
Messages
153
I can't believe how easy this is but I'm still having issues. My original database was corrupted prompting me to need to do this again and i can't find the original source I used to solve this problem.

I have a form (Main_Inventory) that has a button on it with an event procedure behind it. The event procedure opens another form (frm_Transfers_OS) and fills in the field [Item] from the value it pulled from the current form data in Main_Inventory, field [OS_Child]. Here's the code I have so far:

Private Sub Label78_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stlinkcriteria As String
stDocName = "frm_Transfers_OS"
stlinkcriteria = "[Item]=" & "'" & Me![OS_Child] & "'"
DoCmd.OpenForm stDocName, , , stlinkcriteria


The code is not working, needless to say and I can't figure out why. Can anyone help?
 
You can either use OpenArgs at the end of your statement to pick up the data .... DoCmd.OpenForm stDocName, , , stlinkcriteria, Me.txtControlName

and then in the form that is open, set something equal to OpenArgs ...
Me.txtControlName = Me.OpenArgs

Or, if the form you are opening is on top of the other form - you can set the field default value to the form behind it ... = Forms!frmName!txtControlName


-dK
 
I don't want to set the default value of the control to the form behind it simply because I won't always access this form in this manner. I know I did it last time without having to code on both forms as well. I coded only on the original form and it passed the data through to the next form.
 
Then using the OpenArgs method is what you probably want.

-dK
 
Can you give me an example of how I would do that? I've never used that before.
 
I gave you a rough idea in my first post .... Access Help has a pretty good sample (depending on version you have) but there are tons of stuff out there. I only redirect you because I don't know your specific application.

Just do a search for "MS Access OpenArgs" in your favorite search utility - you should get so many hits that you will be thoroughly confused with the many and varied applications of the way you can use this.

-dK
 

Users who are viewing this thread

Back
Top Bottom