Selected Record on switch to another form

D

DarenZ

With a form open, I want to double click on a field to open another form and
modify the contents of that record. Currently I have the following

Private Sub Stock_Number_DblClick(Cancel As Integer)
DoCmd.OpenForm ("Magnify")
Form_Current (Form.Name)

and

Private Sub Form_Current()
Stock_Number.SetFocus

What I want is the second form to open with the focus on the record I double
clicked on. What am I missing?
 
R

Rick A.B.

What I want is the second form to open with the focus on the record I double
clicked on. What am I missing?

Daren,

You have to tell the form your opening what record you want it to
display.

Here's the way I normally do it.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Magnify"

stLinkCriteria = "[linking field on form you are opening]=" & Me!
[linking field on openform]

DoCmd.OpenForm stDocName, , , stLinkCriteria

Rick
 
D

DarenZ

Rick,

I copied what you posted, with my modifications;
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Magnify"

stLinkCriteria = "[Stock_Number]=" & Me![Stock_Number]

DoCmd.OpenForm stDocName, , , stLinkCriteria
Is this correct?

I received this;
run-time error '3075":
Syntax error (missing operator) in query expression
"[Stock_Number]=100500674'.

This is the correct Field I am wanting to "Magnify". Now can you help me the
rest of the way?


Thank you sooo much for your assistance!
Daren
 

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