Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Field Info To Another Form?Any Advice ? 1

Status
Not open for further replies.

435

Technical User
Jul 22, 2003
24
US
Ok I have 2 tables EMPLOYEE & CUSTOMER
both tables have an [red]EMPID[/red] field.

I made two forms one for each table, EMPLOYEE form and
CUSTOMER form. The EMPLOYEE has only one field the [red]EMPID[/red] field
with a command button(START). When I click on this button it takes me to the Customer form. The CUSTOMER form has LastName, and the [RED]EMPID[/RED] field. Ok with that said.

What I want to do is the following....
when I put lets say [RED]7777[/RED] for [RED]EMPID[/RED] on the EMPLOYEE form
and click on the command button which oppens the
CUSTOMER form. I want this form wich contains the [RED]EMPID[/RED]
field to input the [RED]7777[/RED] from the previous form.

Can you guys plz give me a hand with this, I made a sample
but it seems that no attatchments can be put here, I can send the sample db soo you guys know what I'm talking about.

Thaks in advace.
 
in the On Load property of the Customer form include something like this:

me.EMPID.value = Forms!EMPLOYEE!EMPID.value

make sure not to close the EMPLOYEE form before the value is passed.

make sure the references to the form names and field names are exact.

hope this helps you.
 
THANK YOU!!!THAT SURE WORKED!!

...
You said not to close the EMPLOYEE from before the value was passed. I want the EMPLOYEE form to close by itself. Im wondering what code would I need to use If I want the EMPLOYE form to close lets say 4 seconds after
the CUSTOMER form is loaded. So this way the EMPLOYEE form
is open enough time to send the value to the next form.

Is this idea possible?
 
Sorry I forgot,,
the code worked but... only for the first
record on the form.

If i want to add another customer
I would like the value too keep appearing in that field
so the EMPID will be added to each record created
the only things that would change would be the customers
info.

How would i modify the code you gave me to keep that
value for new records created once on the CUSTOMER form?
 
Put this code behind the click event of your command button.

Dim DocName As String, args As Variant
Dim whereclause As String
args = empid
DocName = "frmYourSecondForm"
whereclause = "Empid = " Me.empid
DoCmd.OpenForm DocName, , , whereclause, , , args

On Open event of 2nd Form

Me.AllowFilters = True
Me.FilterOn = true

The Me.OpenArg on the second Form will be passed the empid and available for your use.

The whereclause will be loaded into the filter on the 2nd Form.
 
Enter the code (me.EMPID.value = Forms!EMPLOYEE!EMPID.value) in the On Current property/procedure.

did this help?
 
sorry 435,

now that i think about it, i don't think what i told you will work in the On Current event if the text box is tied to
a field in the table. if you go to create a new record it will probably "blank" out the EMPID field.

enter the code in the Before Update procedure. when you go to create a new record, when you begin entering data for the new record the EMPID field should populate.

question?...are you creating a new record (adding a new customer) via a command button? if so, you might try putting the code in the On Click event that creates/adds the new customer.

let me know how it goes.



 
cghoga, the code you gave me worked fine

(me.EMPID.value = Forms!EMPLOYEE!EMPID.value)

Thats part of what I wanted, the thing is that this fills
in the EMPID on the form opened but only for the first record, when I go to create a new record the EMPID goes blank, and what I want to do is to keep the EMPID trough out
the rest of the update or creation of new records on the CUSTOMER form.

what modifications do you suggest me?
 
sorry again 435,

insert the code in the Before Insert procedure of the form.

when you go to create a new record, the EMPID will not autofill immediately, but when you begin to enter (insert) data for the new record the EMPID should autofill.

i made another post just before your last post. after i sent you a previous post i realized the On Current event would not work. sorry for the inconvenience.

for this method to work the EMPLOYEE form must remain open.

if you want the EMPLOYEE form to close automatically, you will not be able to reference the EMPID from the EMPLOYEE form for any new records created. If the form must be closed, you might consider setting a text box within the header on the CUSTOMER form to the EMPID value on the EMPLOYEE form.
then, in the detail, set the value of the EMPID in each new record you insert to the field value you created in the header.

try the Before Insert procedure and let me know how it goes.
 
cghoga
Ok,

"question?...are you creating a new record (adding a new customer) via a command button? if so, you might try putting the code in the On Click event that creates/adds the new customer"

The idea is to create or modify a record and saving changes
On Click event, I did what you suggested it and I have the
code on the command button (SAVE)and after I modify or add
a new record and click on the (SAVE)button it fills in
the EMPID number atomatically.


Here is the code behind that button....

Private Sub svbtn_Click()
On Error GoTo Err_svbtn_Click

Me.EMPID.Value = Forms!EMPLOYEE!EMPID.Value
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_svbtn_Click:
Exit Sub

Err_svbtn_Click:
MsgBox Err.Description
Resume Exit_svbtn_Click

End Sub


Thanks for the great help. It sure worked!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top