Open Record by selecting on another form.

F

feeman

Hi

I have a database that lists outstanding orders customers have, On
the event procedure for txtbox Order Number on the currently opened
form outstanding orders, I have selected that on double click it will
open the form orders to the appropraite record. ie in the outstanding
orders if fred has an order and you double click on the order number
it opens up freds order from the orders form. I have used a where
statement but must have got it wrong can someone point me in the right
direction first time I have used the where statement.

Private Sub Order_Number_DblClick(Cancel As Integer)

Dim strWhere

strWhere = "me.[Order Number]" = " & forms!Orders.[Order Number]"

DoCmd.OpenForm "orders", , , strWhere


End Sub
 
T

tina

looks like you have the statement "turned around". on the left side of the
equation, you should refer to the field *in the recordsourse of the form
that you're opening*. so get rid of the

me.

and just use the fieldname. on the right side of the equation, you're
refering to the field in the calling form (the form that the code is running
in). so get rid of the complete form reference, and just use the Me.
keyword. also, you've left the equal sign *outside* of double quotes, where
it can't be read. try the following, as

strWhere = "[Order Number] = " & Me![Order Number]

if order number is a Text data type, rather than a number, you must enclose
the value in quotes, as

strWhere = "[Order Number] = '" & Me![Order Number] & "'"

hth
 

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