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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coding problem for opening form, finding record 1

Status
Not open for further replies.

jweber

MIS
Nov 4, 2002
28
US
Hello.

I am working on a workorder form that, after an update, opens and finds the inventory record in another form. I keep getting "Run-time error '2501': The OpenForm action was canceled.

This is what my code looks like.

If Me.Dirty Then ConfirmChg
DoCmd.OpenForm "EmpAudit1", , , "[EmpID]='" & Me![EmpID] & "'"

Help!
Thanks in advance...
 
Is EmpID numeric? If so, you'll have to get rid of the single quotes, like so:
DoCmd.OpenForm "EmpAudit1", , , "[EmpID]=" & Me![EmpID]

Jeremy ==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
YOU ARE SO VERY AWESOME!

That worked. Just for future knowledge...why does that happen? I am a beginning programmer working as a MIS intern, and I am not too familiar with Visual Basic, and I am teaching myself....

Thanks again for your help...
 
Jweber,

I'm glad you saw that as a helpful post. The reason it works is that strings of text must be offset in single quotes, dates must be offset is # signs, and numbers don't need to be offset it anything.

Jeremy ==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top