More Detail Button

F

Fahad

Dear

I have form (its name is frmproduct) containing the following records (the
resource record is Products table):
Barcode ----> primary key
itemName ----> Memo
ItemNo ----> Number

the primary key (barcode) has this format X10-1234
I creaded a parameter query (its name is FindProduct) to search on the
itemname. if I run this query, it will give me a pop up box asking to enter
any part of the item name. the query works fine.
I created a new form (its name is frmFindProduct) based on this query, when
i open this form it'll give me a pop up box asking to enter any part of the
item name. and i get the needed result. on this form I created a command
button, when i click it, it should open the main form (frmProduct) to see
more details about the product.
the following code has been embeded on this button, when i click it:

Private Sub cmdProductRecDetail_Click()
' Open the details for the selected record on the related form
DoCmd.OpenForm "frm_product", wherecondition:="barcode = " & Me.BarCode
End Sub

when I click the button to see more detail, it give me a pop up box asking
me to enter the remaining part of the barcode (primar Key). (i.e. the part
after X10).

could you please help me to solve this issue?
 
R

Robert L. Austin

My first guess is that the following part of your code
DoCmd.OpenForm "frm_product", wherecondition:="barcode = " & Me.BarCode
.... I beleive Me.BarCode is the name of your search box where the user is
entering a portion of the field.
If this is the case, then what you are wanting to do is change what field
the WhereCondition is searching on. My reommendation is actually the
Primary Key field.

Now that I look at it closer, the Me.BarCode, should actually be the Primary
Key field, but the Me. says that you are referencing the Form control name,
which may not necessarily be the name of the data field that you are using -
though usually it is, so now I'm at a a loss.

I do believe that you are running into some sort of referencing issue,
similar to what I am saying - though after taking a second look, I think I'm
close to what's wrong, but I do believe I'm slightly off the mark.

In order to find out exactly, I believe I would need to look at the database
file. If you are willing and able to, go ahead and send the file directly
to my email account (e-mail address removed) (remove the X's (you may want
to remove any of the other objects and unrelated tables/queries/etc.)
 
D

Dirk Goldgar

Fahad said:
Dear

I have form (its name is frmproduct) containing the following records (the
resource record is Products table):
Barcode ----> primary key
itemName ----> Memo
ItemNo ----> Number

the primary key (barcode) has this format X10-1234
I creaded a parameter query (its name is FindProduct) to search on the
itemname. if I run this query, it will give me a pop up box asking to
enter
any part of the item name. the query works fine.
I created a new form (its name is frmFindProduct) based on this query,
when
i open this form it'll give me a pop up box asking to enter any part of
the
item name. and i get the needed result. on this form I created a command
button, when i click it, it should open the main form (frmProduct) to see
more details about the product.
the following code has been embeded on this button, when i click it:

Private Sub cmdProductRecDetail_Click()
' Open the details for the selected record on the related form
DoCmd.OpenForm "frm_product", wherecondition:="barcode = " & Me.BarCode
End Sub

when I click the button to see more detail, it give me a pop up box asking
me to enter the remaining part of the barcode (primar Key). (i.e. the part
after X10).

could you please help me to solve this issue?


If BarCode is a text field, you need to enclose the value in quotes:

DoCmd.OpenForm "frm_product", _
WhereCondition:="barcode = '" & Me.BarCode & "'"

In this case, I've used single-quotes ('), assuming that no barcode will
ever contain that character.
 

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