Update form based on form

xaysana

Registered User.
Local time
Today, 07:03
Joined
Aug 31, 2006
Messages
94
Hi there,

I have a form called "main", in a main form has one text field called "employeename". I also have created a popup form "frmemployee" to link with employeename field in main form when i double click on employeename text field.
What i want it to happen is that when i select or copy any employeename in frmemployee that select, after i click close button or hit enter on keyboard to close and paste the particular employeename into the employeename text field in main form.

Any help is appreciated.

Thank you in advance
Cheers,
 
The attached may help.

May need a requery or refresh too.

Good luck

Thank you Ted for your share
That is very useful syntax.

In fact, I found other way to work on this. My cord is working fine except when the ID field = Null in frmemployee form then it appears error (Runtime error 94 "Invalid use of Null" End / Debug. How do i get around this?

Here is the code:

Private Sub Close_Click()

If CurrentProject.AllForms("Data Entry").IsLoaded Then

Dim NewHHID As Long
NewHHID = Me!HHID.Value

DoCmd.Close

Forms![Data Entry]!Household.Value = NewHHID

End If

End Sub
 
Last edited:
There are two ways to trap the Null error.

Method 1 is to use the On Error trapping routine

At the very top of your code module insert

Code:
On Error GoTo Err_ID

just before the End Sub insert

Code:
Exit_ID:
Exit Sub

Err_ID:

if err.number = 94 then
resume Exit_ID
else
msgbox Err.Description, vbcritical,Err.number & " ID"
end if

End Sub

The other way which is in my view a little more classy is to Check the ID for Null before running your code

Code:
If len(ID.value & "") = 0 then
' do something here
end if
 

Users who are viewing this thread

Back
Top Bottom