combo box/command button used to open a report: How?

G

Guest

I have a form with a combo box, based on a query showing the primary key
(StudentKey) and the student’s name. The combo box is bound to the first
column (StudentKey). The combo box is named “Keyâ€. Column widths are 0â€,1â€

I have a command button next to the combo box that I want to open a report
to show only the data for the student selected. The report has the
StudentKey field on it. I’ve tried several coding things with the “on clickâ€
event on the button, but nothing has worked properly. Here’s my latest try
(it generates the error that Access can’t find the field “|†used in the
expression).

Dim stDocName As String
Dim stLinkCriteria As Integer

stDocName = "Billings-AccountHistory"
stLinkCriteria = [StudentKey] = Me![Key]

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

I know it has something to do with how I write the condition statement, but
I haven’t landed on the right way yet.

Thanks in advance.

Jerry
 
G

Guest

Got rid of the one error, now I'm getting a "type mismatch" error when I
click the button.

Albert D. Kallal said:
stDocName = "Billings-AccountHistory"
stLinkCriteria = [StudentKey] = Me![Key] close!!!

Try

stLinkCriteria = "[StudentKey] = " & Me![Key]
 
G

Guest

Fixed it. The stLinkCriteria variable was dim as an integer. Had to change
it to a string.

JWCrosby said:
Got rid of the one error, now I'm getting a "type mismatch" error when I
click the button.

Albert D. Kallal said:
stDocName = "Billings-AccountHistory"
stLinkCriteria = [StudentKey] = Me![Key] close!!!

Try

stLinkCriteria = "[StudentKey] = " & Me![Key]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top