transfer company name from one form to another form (1 Viewer)

peterjb44

Registered User.
Local time
Today, 10:52
Joined
Mar 7, 2013
Messages
55
Hi All,

been trying to figure this out..

i have a customer form and on the form i got a button to add equipment which opens another form, my question is how can i get the same company name from the customer form to be in the equipment form once i press the button?

i have done this so far

docmd.openform "EquipmentF",,,(not sure what to put here....i've tried "company = '" & company & "'" but this just seems to open the first company)

thanks

peter
 

AlexHedley

Registered User.
Local time
Today, 10:52
Joined
Aug 28, 2012
Messages
171
You could add a textbox to the Form then set it to
Code:
=Forms!frmCustomer!Company
Where frmCustomer is the name of your Customer Form and Company is the name of the Field you store your Company in.

I take it both Forms are based on different Tables.
How are you relating them?
Are you wanting the second Form to open with data pre filled or be blank.
 

peterjb44

Registered User.
Local time
Today, 10:52
Joined
Mar 7, 2013
Messages
55
Hi Alex,

Thanks for your reply, yes both forms are based on different tables....CustomerT and EquipmentT

Company field in CustomerT is related 1 to many to CompanyID of EquipmentT

the only data i need pre filled is the current Company in CustomerF form which is open then when i click button it opens EquipmentF which the same company (CompanyID)

EquipmentF CompanyID field is a combo box


thanks

peter
 
Last edited:

peterjb44

Registered User.
Local time
Today, 10:52
Joined
Mar 7, 2013
Messages
55
Hi Alex,

thanks, that works, but i also can open EquipmentF from another button on my navigation main form and now i get name? in the CompanyID

is it not possible to do code for my OP?
how can i get rid of name? which is now on EquipmentF when i click the other button?


thanks for your help


peter
 

peterjb44

Registered User.
Local time
Today, 10:52
Joined
Mar 7, 2013
Messages
55
Hi Alex,


I've got a datasheet open all the time SubEquipmentFDS which has CompanyID on it, can that be used?

thanks

peter
 

AlexHedley

Registered User.
Local time
Today, 10:52
Joined
Aug 28, 2012
Messages
171
Is this a Form in datasheet view or a Table that's open.
Would it have multiple Companies?

In the intermediate window try
? Me.Field1.Value
Or try using
MsgBox Me.Field1.Value
 

AlexHedley

Registered User.
Local time
Today, 10:52
Joined
Aug 28, 2012
Messages
171
Another option would be setting a control on the Form in vba after the Form has opened.
That way it doesn't need to reference a particular Form as it's set per button click
 

peterjb44

Registered User.
Local time
Today, 10:52
Joined
Mar 7, 2013
Messages
55
Hi Alex,

it is a form in datasheet view, yes it has multiple companies on it

thanks

peter
 

peterjb44

Registered User.
Local time
Today, 10:52
Joined
Mar 7, 2013
Messages
55
Another option would be setting a control on the Form in vba after the Form has opened.
That way it doesn't need to reference a particular Form as it's set per button click

not sure how to do this :confused:
 

peterjb44

Registered User.
Local time
Today, 10:52
Joined
Mar 7, 2013
Messages
55
Hi All,

this is weird......

it works only if my customer already has equipment that has been added to their company, but it shows that equipment data including company and not a blank form with only the company name in :confused:

this is the code i am using

Code:
private sub AddEquipmentButton_Click()
  DoCmd.OpenForm "EquipmentF",,,"CompanyID = '" & Me.Company & "'",,acDialog
End Sub

any ideas??

peter
 

Users who are viewing this thread

Top Bottom