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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|