Open From From Subform Where Condition

tarcona

Registered User.
Local time
Today, 16:52
Joined
Jun 3, 2008
Messages
165
I know this has been brought up, and I have tried EVERYTHING to solve this problem, but it still wont work.

I have tried DoCmd.OpenForm "SalesWon", , , "LeadID = " & Me.LeadID
but I might be doing it wrong. I dont know.

Open Add/EditRecords
And if you go down to the Lead Information section you will see the Disposition combo box. And if you choose 'Won', 'SalesWon' form should pop-up. I made 3 or 4 records for 'SalesWon'. As you can see 'SalesWon' and the 'LeadInformation Subform' are connected by 'Lead ID' field. If there is a record in the 'SalesWon' form that has the same 'Lead ID' field as the subform, I want that record to show. If there are no matches, I want the form to open to a new record. Thanks.
 

Attachments

I didn't open your file but I immediately see a problem. Change:
Code:
DoCmd.OpenForm "SalesWon", , , "LeadID = " & Me.LeadID

To:
Code:
DoCmd.OpenForm "SalesWon", , , "LeadID = '" & Me.LeadID & "'"

and see if that gets you a better result.
 
Forgot to mention...I did try that as well.
I also tried to create a Macro and put in a Where condition but that didnt work.
 
OK, you have a problem with names. There is no such field or control on either form as "LeadID". You do, however, have a field on each form called "Lead ID", which is somewhat different. Fixing that will get you past this error (and on to the next error).

I really suggest that you rename all your controls with a standard prefix and remove all spaces from the names. For instance, you should rename the text control "Lead ID" to something like txtLeadID. You should also take advantage of VB's nice auto-complete/Intellisense feature to help type in names of things.

Since I never, ever, use Docmd.Openform (and likely never will), I don't have much to say about that. You should make sure you are using the filter correctly, once you have the naming problem resolved.
 

Users who are viewing this thread

Back
Top Bottom