filter by form field

G

Guest

I can't quite get this right:

I have a form: "Cashiering"

It has a combo called "findbybidnumber" that finds a particular record and
displays it on the form, based on the field "bidnumber"

I made a button called "print_invoice" to open a report "Item Invoice" which
I would like filtered by "bidnumber" on my form, which is the same number
also displayed in "findbybidnumber"

Problem is, the field on my report is also called "bidnumber" and I can't
get the syntax right.

Private Sub print_invoice_Click()
Dim strWhere As String

strWhere = "[bidnumber] = " & [bidnumber]
DoCmd.OpenReport "Item Invoice", acViewPreview, , strWhere
End Sub
 
D

Duane Hookom

What's the error or issue? What doesn't work? What is the data type of
BidNumber?
 
G

Guest

"bidnumber" is a numeric field.

"Run-time error '3079':
The specified field 'bidnumber' could refer to more than one table listed in
the FROM clause of your SQL statement."

I take it to mean that the names of the field are both the same, starting
point and desination.

Duane Hookom said:
What's the error or issue? What doesn't work? What is the data type of
BidNumber?

--
Duane Hookom
MS Access MVP

miss031 said:
I can't quite get this right:

I have a form: "Cashiering"

It has a combo called "findbybidnumber" that finds a particular record and
displays it on the form, based on the field "bidnumber"

I made a button called "print_invoice" to open a report "Item Invoice"
which
I would like filtered by "bidnumber" on my form, which is the same number
also displayed in "findbybidnumber"

Problem is, the field on my report is also called "bidnumber" and I can't
get the syntax right.

Private Sub print_invoice_Click()
Dim strWhere As String

strWhere = "[bidnumber] = " & [bidnumber]
DoCmd.OpenReport "Item Invoice", acViewPreview, , strWhere
End Sub
 
D

Duane Hookom

Your report has two or more tables each with bidnumber appearing in the SQL
statement. Don't include duplicate field names in queries.

--
Duane Hookom
MS Access MVP


miss031 said:
"bidnumber" is a numeric field.

"Run-time error '3079':
The specified field 'bidnumber' could refer to more than one table listed
in
the FROM clause of your SQL statement."

I take it to mean that the names of the field are both the same, starting
point and desination.

Duane Hookom said:
What's the error or issue? What doesn't work? What is the data type of
BidNumber?

--
Duane Hookom
MS Access MVP

miss031 said:
I can't quite get this right:

I have a form: "Cashiering"

It has a combo called "findbybidnumber" that finds a particular record
and
displays it on the form, based on the field "bidnumber"

I made a button called "print_invoice" to open a report "Item Invoice"
which
I would like filtered by "bidnumber" on my form, which is the same
number
also displayed in "findbybidnumber"

Problem is, the field on my report is also called "bidnumber" and I
can't
get the syntax right.

Private Sub print_invoice_Click()
Dim strWhere As String

strWhere = "[bidnumber] = " & [bidnumber]
DoCmd.OpenReport "Item Invoice", acViewPreview, , strWhere
End Sub
 
G

Guest

Thank you, I added the table name to all of the field names, and now
everything is good.

Duane Hookom said:
Your report has two or more tables each with bidnumber appearing in the SQL
statement. Don't include duplicate field names in queries.

--
Duane Hookom
MS Access MVP


miss031 said:
"bidnumber" is a numeric field.

"Run-time error '3079':
The specified field 'bidnumber' could refer to more than one table listed
in
the FROM clause of your SQL statement."

I take it to mean that the names of the field are both the same, starting
point and desination.

Duane Hookom said:
What's the error or issue? What doesn't work? What is the data type of
BidNumber?

--
Duane Hookom
MS Access MVP

I can't quite get this right:

I have a form: "Cashiering"

It has a combo called "findbybidnumber" that finds a particular record
and
displays it on the form, based on the field "bidnumber"

I made a button called "print_invoice" to open a report "Item Invoice"
which
I would like filtered by "bidnumber" on my form, which is the same
number
also displayed in "findbybidnumber"

Problem is, the field on my report is also called "bidnumber" and I
can't
get the syntax right.

Private Sub print_invoice_Click()
Dim strWhere As String

strWhere = "[bidnumber] = " & [bidnumber]
DoCmd.OpenReport "Item Invoice", acViewPreview, , strWhere
End Sub
 
G

Guest

I think you missed my point of never including duplicate field names. You can
alias filed/columns but this should only be used if the columns don't contain
the same value as another column in the query.
--
Duane Hookom
Microsoft Access MVP


miss031 said:
Thank you, I added the table name to all of the field names, and now
everything is good.

Duane Hookom said:
Your report has two or more tables each with bidnumber appearing in the SQL
statement. Don't include duplicate field names in queries.

--
Duane Hookom
MS Access MVP


miss031 said:
"bidnumber" is a numeric field.

"Run-time error '3079':
The specified field 'bidnumber' could refer to more than one table listed
in
the FROM clause of your SQL statement."

I take it to mean that the names of the field are both the same, starting
point and desination.

:

What's the error or issue? What doesn't work? What is the data type of
BidNumber?

--
Duane Hookom
MS Access MVP

I can't quite get this right:

I have a form: "Cashiering"

It has a combo called "findbybidnumber" that finds a particular record
and
displays it on the form, based on the field "bidnumber"

I made a button called "print_invoice" to open a report "Item Invoice"
which
I would like filtered by "bidnumber" on my form, which is the same
number
also displayed in "findbybidnumber"

Problem is, the field on my report is also called "bidnumber" and I
can't
get the syntax right.

Private Sub print_invoice_Click()
Dim strWhere As String

strWhere = "[bidnumber] = " & [bidnumber]
DoCmd.OpenReport "Item Invoice", acViewPreview, , strWhere
End Sub
 

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