Tom Crowfoot
asked on
OPen form Add mode & pass data across
Dear Experts,
I want to be able to open up a pop up form to add data, and also populate 1 field from the original form:
The forms & fields are as follows:
The form from which the pop up is launched is "Employee" & has a field [EmployeeID] which I want to to take across to the pop up form.
The pop up form is "AddHRLog" & the field to be populated is [EmployeeID]
So basically when the pop up opens it fills in EmployeeID with the details from Employee.EmployeeID
I have got this far ...
Can anybody help?
I want to be able to open up a pop up form to add data, and also populate 1 field from the original form:
The forms & fields are as follows:
The form from which the pop up is launched is "Employee" & has a field [EmployeeID] which I want to to take across to the pop up form.
The pop up form is "AddHRLog" & the field to be populated is [EmployeeID]
So basically when the pop up opens it fills in EmployeeID with the details from Employee.EmployeeID
I have got this far ...
DoCmd.OpenForm "AddHRLog", , , , acFormAdd
Can anybody help?
If you are using Access 2007 or higher you can also use TempVars for this:
http://blogs.msdn.com/b/thirdoffive/archive/2006/04/13/570539.aspx
http://blogs.msdn.com/b/thirdoffive/archive/2006/04/13/570539.aspx
Here's another article about TempVars:
http://blogs.office.com/b/microsoft-access/archive/2010/09/27/power-tip-maximize-the-user-of-tempvars-in-access-2007-and-2010.aspx
I don't have Access 2007 handy but I believe the syntax in your case would be:
And in the popup form's Open Event:
http://blogs.office.com/b/microsoft-access/archive/2010/09/27/power-tip-maximize-the-user-of-tempvars-in-access-2007-and-2010.aspx
I don't have Access 2007 handy but I believe the syntax in your case would be:
TemVars.Add "lngEmployeeID", Me.EmployeeID
DoCmd.OpenForm "AddHRLog", , , , acFormAdd
And in the popup form's Open Event:
Me.EmployeeID = TempVars("lngEmployeeID")
ASKER
Hi
Thanks for this - am struggling to get this to work:
In the 1st form I have ...
I have added in the .Value as I was getting an error saying "TempVars can only store data. They cannot store objects"
I'm not sure if it makes a difference but both fields are numbers
In the pop up form I have...
Any ideas?
Thanks for this - am struggling to get this to work:
In the 1st form I have ...
TempVars.Add "lngEmployeeID", Me.EmployeeID.Value
DoCmd.OpenForm "AddHRLog", , , , acFormAdd]
I have added in the .Value as I was getting an error saying "TempVars can only store data. They cannot store objects"
I'm not sure if it makes a difference but both fields are numbers
In the pop up form I have...
Private Sub Form_Open(Cancel As Integer)
Me.EmployeeID = TempVars!lngEmployeeID
End Sub
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In your popup form the tempvars syntax should be
tempvars("lngEmployeeID")
tempvars("lngEmployeeID")
ASKER
Hi both
thanks for these - I'll give them both a go in the morning when I'm back at the PC - I'll double check, but I think I tried that syntax from mbizup, but will give it a go again
thanks for these - I'll give them both a go in the morning when I'm back at the PC - I'll double check, but I think I tried that syntax from mbizup, but will give it a go again
ASKER
Thanks for this works a treat
Open in new window
And in the open event of your popup form:
Open in new window