Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing forms causes OpenForm action to cancel

Status
Not open for further replies.

RikHess

MIS
Jul 25, 2002
69
US
I know I have done this before but today it is just giving me grief.

I have set up a DB with one table and two forms. First form is a list of the table recs, and the second form displays a single rec when the list line is double-clicked.

Fist form uses a query to show the table recs, and the second (detail) form uses the table as the data source with record lock on the edited rec.

The list displays fine, but when I double-click on an entry I get Error '2501', The OpenForm action was canceled.

This is the code I use to open the second form:
Code:
    s_Form = "frm_People"
    s_Cond = "[ID] = '" & LstPeople.Column(0) & "'"
    
    DoCmd.OpenForm s_Form, _
        WhereCondition:=s_Cond

I'm using Access 2003 if that matters. The MS Knowledgebase has only one entry for error 2501 which pertains to print drivers. That's not my problem.

Can someone point me in the right direction?

Thanks for any help!
 
This is probably more a forms question than Modules, but what kind of datatype is your ID field? If it's numeric, drop the text delimiters

[tt]s_Cond = "ID = " & LstPeople.Column(0)[/tt]

If it's text, then you'd need to check out whether the first column of the list contains the id, or somethin else - anyway, if the first column is also the bound column, you could use

[tt]s_Cond = "ID = " & LstPeople ' or
s_Cond = "ID = " & LstPeople.Value[/tt]


i think.

Roy-Vidar
 
Thank you!
And DUH!

That's what happens when you copy code from one project to another.

Best Wishes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top