A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

filling fields on linked forms automatically



 
 
Thread Tools Display Modes
  #1  
Old June 10th, 2004, 11:40 AM
Polly
external usenet poster
 
Posts: n/a
Default filling fields on linked forms automatically


Hello,

I have two forms.

The first is [Company], fields: companyID (primary), CompanyName,
Website.

The second is [Contact], fields: ContactID (primary), Company ID,
Title, FirstName,Surname etc.


There is a command button on [Company] that links to the second form,
[Contact].

What I would like, is when you open the [Contact] form from this link,
the [CompanyID] field is automatically filled. (This is the field they
are linked together by)

Any help would be greatly appreciated (I'm not all that experienced
with access, and can have problems with VBA - although I am getting
better!)

Polly


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

  #2  
Old June 11th, 2004, 08:11 AM
Nikos Yannacopoulos
external usenet poster
 
Posts: n/a
Default filling fields on linked forms automatically

Polly,

You are not clear on what you want to do with the second form: open it for
new data entry, or just filter existing records on the CompanyID?
In the first case, the code should be something like:

cid = Me.CompanyID
DoCmd.OpenForm "Contact", acNormal, , , acFormAdd
Forms!Contact.CompanyID = cid

In the second case:
cid = Me.CompanyID
DoCmd.OpenForm "Contact", acNormal, , "[CompanyID] = " & cid
(if CompanyID is numeric, or)
cid = Me.CompanyID
DoCmd.OpenForm "Contact", acNormal, , "[CompanyID] = ' " & cid & " ' "
(if CompanyID is text).

In any case, make sure the names are spelled correctly.

HTH,
Nikos

"Polly" wrote in message
...

Hello,

I have two forms.

The first is [Company], fields: companyID (primary), CompanyName,
Website.

The second is [Contact], fields: ContactID (primary), Company ID,
Title, FirstName,Surname etc.


There is a command button on [Company] that links to the second form,
[Contact].

What I would like, is when you open the [Contact] form from this link,
the [CompanyID] field is automatically filled. (This is the field they
are linked together by)

Any help would be greatly appreciated (I'm not all that experienced
with access, and can have problems with VBA - although I am getting
better!)

Polly


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



  #3  
Old June 14th, 2004, 10:56 AM
Polly
external usenet poster
 
Posts: n/a
Default filling fields on linked forms automatically


Hi Nikos,

Apologies for not being clearer, I am indeed opening it for new data
entry so this is great stuff.

Thanks very much for your help,

Polly


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:49 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.