Problem Linking Related Forms

awalker2009

New Member
Joined
Jun 17, 2014
Messages
6
Hello,

I have a problem with 2 related forms in a database I'm building, where a macro is not opening the correct record. . The database hold details of service providers, who have contracts with our organisation.

One form holds the basic details of the provider (Name, reference, type of organisation). the other has the contact details. There is a button which should take the user to the second form which will have the contact details for that provider. However, whenever I click the button, the form opens for a different provider (one that's the first in the underlying table).

The macro I am using is as follows:

Close Window
Object Type: Form
Object Name: frmProviderBasicDetails
Save: No

Open Form
Form Name: frmProviderGeneralContact
View: Form
Filter Name:
Where Condition = ="[Provider Name]=" & "'" & [cbofrmProviderBasicDetailsProviderName] & "'"
Data Mode:
Window Mode: Normal

where:
frmProviderBasicDetails =starting form

frmProviderGeneralContact = related form to be opened

[Provider Name] = field name of provider in related form

[cbofrmProviderBasicDetailsProviderName] = name of box containing provider name in originating form

Thanks
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
are you sure 'cbofrmProviderBasicDetailsProviderName' has the correct value?
if the combo bound column is wrong then it will give the wrong value.

Do the providers have record ID? Its best to use the ID rather than the 'name'.
the combo would show the name, but the bound column would be set to [id] and the col.width = 0 so the user cant see it.

and you have too many quotes and commas, no brackets:
docmd.OpenForm "
frmProviderGeneralContact",,,"[Provider Name]='" & cbofrmProviderBasicDetailsProviderName & "'"

 
Upvote 0
I agree that you should be sing the record primary key (usually an auto number field) and not the name

Where Condition = ="[Provider Name]=" & "'" & [cbofrmProviderBasicDetailsProviderName] & "'"

If this were my project I would use frmProviderGeneralContact as a sub form on frmProviderBasicDetails. Access makes this very easy. NO code or macro required!
 
Upvote 0

Forum statistics

Threads
1,221,845
Messages
6,162,350
Members
451,760
Latest member
samue Thon Ajaladin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top