ComboBox selection to report

  • Thread starter Thread starter msam137
  • Start date Start date
M

msam137

Hello I am trying to create a editable translator database. The user
wants to be able to one word or phrase from a cboWords and be able to
have the results printed. But everytime I cllick on the findword
button I get a dialog asking me to enter the word and then after I hit
enter the report opens but it is not filtered it shows all the words
and translation enter.

Private Sub Command3_Click()
Dim strDocName As String
Dim strForm As String
On Error GoTo Err_Search_Click

strDocName = "rptEnglish"

DoCmd.OpenReport strDocName, acViewPreview, , "English = '" & Me!
cboEng_Word.Value & "'"

Exit_Command3_Click:
Exit Sub

Err_Search_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
 
It's difficult to say where the problem is, but here are a few things to check.

First, the word English is probably a bad name for a field. I can't say for sure
that it's a KeyWord, but it could be, so from now on, you should always enclose
it with brackets. like this [English].

You'll find this to be true if you name fields as [Select], [Form], [Column] etc.

Second, are you sure what's coming back from cboEng_Word? Try writing the
value to the Debug window, like this ...

Dim strCriteria as String

strCriteria = "[English]= '" & Me!cboEng_Word.Value & "'"
Debug.Print strCriteria

DoCmd.OpenReport strDocName, acViewPreview, , strCriteria

At least this will tell you what's being passed to rptEnglish.

Next, the report must, of course, have the column [English] in it's field list.
 
It's difficult to say where the problem is, but here are a few things to check.

First, the word English is probably a bad name for a field. I can't say for sure
that it's a KeyWord, but it could be, so from now on, you should always enclose
it with brackets. like this [English].

You'll find this to be true if you name fields as [Select], [Form], [Column] etc.

Second, are you sure what's coming back from cboEng_Word? Try writing the
value to the Debug window, like this ...

Dim strCriteria as String

strCriteria = "[English]= '" & Me!cboEng_Word.Value & "'"
Debug.Print strCriteria

DoCmd.OpenReport strDocName, acViewPreview, , strCriteria

At least this will tell you what's being passed to rptEnglish.

Next, the report must, of course, have the column [English] in it's field list.
--
Danny J. Lesandrini
(e-mail address removed)

Hello I am trying to create a editable translator database. The user
wants to be able to one word or phrase from a cboWords and be able to
have the results printed. But everytime I cllick on the findword
button I get a dialog asking me to enter the word and then after I hit
enter the report opens but it is not filtered it shows all the words
and translation enter.
Private Sub Command3_Click()
Dim strDocName As String
Dim strForm As String
On Error GoTo Err_Search_Click
strDocName = "rptEnglish"
DoCmd.OpenReport strDocName, acViewPreview, , "English = '" & Me!
cboEng_Word.Value & "'"
Exit_Command3_Click:
Exit Sub
Err_Search_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub

Thanks Danny for the quick response I also made some other changes.
You were right English was not the name of the field on the report.
 
Back
Top