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

Combo Box choice won't open form 1

Status
Not open for further replies.

TammyT

Programmer
Sep 17, 2003
183
US
Okay, this should be so easy, but I'm stuck!

I have a table - tblFaceSheet - stores the values that pull to a form. I also created qryFaceSheet for the data in the table.

I have a form for users to select which review they wish to edit - simple combo box (cboSelectCase) that has the review #, the case name, & the review date (I'm basing the cbo on the qry from the FaceSheet table). Review # is primary key, but they won't know that info - they'll need to see the name/date combo to pick the record they want to edit.

The "Go" button on the form with the combo box is supposed to open frmReviewEdit, & it's supposed to populate the form with the info from the table (or query - which is better to use?) based on the choice in the combo box. This must be the easiest, most obvious code in the world! But I'm getting a run-time error on it.

Here's the code:

Private Sub cmdEditReview_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmFaceSheetEdit"
stLinkCriteria = "[Review_No] ='" & cboSelectCase & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit
DoCmd.RunCommand acCmdFilterByForm
DoCmd.Maximize

End Sub


On the form, for the cbo, I have a column count of 3, bound column of 1, & the column widths set to 0",2",1" - this way the review # doesn't show, just the name & date.

In the code, [Review_No] refers to the field in the table storing the review # - that's probably obvious, but didn't want to leave anything to guesswork for you!

Okay, so when I try to open the form, I get run-time error 2501 - and the line it's stopping on is

DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit

So, what obvious piece am I missing here????

Thanks!
 
If review number is numeric you may try removing the single quotes from the link criteria.

I tried to have patience but it took to long! :) -DW
 
See? I knew it was something obvious!!!

Of course, I didn't actually "write" that code - did a copy/paste from another Db, & was given that code to use there!

See what happens when amateurs try to do code? !!

=)

Thanks - that's all it was.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top