DoCmd.OpenForm

G

GMC

Access 2000

Hello all,

I have a form that lists some problems in it. I want to be able to double
click on the field named ID in the form and open the detailed version in
"inpProblems". The table that has the details in it is named "Problems". I
have the following which opens the first record in the table "Problems"
instead of opening the ID number on which I double clicked on.

Private Sub ID_DblClick(Cancel As Integer)
DoCmd.OpenForm "inpProblems", acNormal, "Problems.ID ="""
End Sub

How do I change it so it opens up the detail of the id number I just clicked
on?

Thanks
 
D

Dirk Goldgar

GMC said:
Access 2000

Hello all,

I have a form that lists some problems in it. I want to be able to double
click on the field named ID in the form and open the detailed version in
"inpProblems". The table that has the details in it is named "Problems".
I have the following which opens the first record in the table "Problems"
instead of opening the ID number on which I double clicked on.

Private Sub ID_DblClick(Cancel As Integer)
DoCmd.OpenForm "inpProblems", acNormal, "Problems.ID ="""
End Sub

How do I change it so it opens up the detail of the id number I just
clicked on?


Try this and see how it works:

DoCmd.OpenForm "inpProblems", acNormal, "ID=" & Me!ID

Note: that assumes that ID is a numeric field. If ID is a text field, try
this instead:

DoCmd.OpenForm "inpProblems", acNormal, "ID='" & Me!ID & "'"
 
F

fredg

Access 2000

Hello all,

I have a form that lists some problems in it. I want to be able to double
click on the field named ID in the form and open the detailed version in
"inpProblems". The table that has the details in it is named "Problems". I
have the following which opens the first record in the table "Problems"
instead of opening the ID number on which I double clicked on.

Private Sub ID_DblClick(Cancel As Integer)
DoCmd.OpenForm "inpProblems", acNormal, "Problems.ID ="""
End Sub

How do I change it so it opens up the detail of the id number I just clicked
on?

Thanks

You didn't place the Where clause argument in the correct position,
nor did you complete it.

DoCmd.OpenForm "inpProblems", acNormal, , "[ID] =" & [ID]

The above assumes there is a control named ID on this form and that
the ID field in the Problems table is a Number datatype.

If, however the [ID] field is Text datatype, then use:

DoCmd.OpenForm "inpProblems", acNormal, , "[ID] ='" & [ID] & "'"

In any event, the Where clause must be placed in the 4th argument
position. You had it in the 3rd position.
 
D

Dirk Goldgar

Dirk Goldgar said:
Try this and see how it works:

DoCmd.OpenForm "inpProblems", acNormal, "ID=" & Me!ID


FredG spotted what I failed to see -- you need the extra comma, as he
pointed out:

DoCmd.OpenForm "inpProblems", acNormal, , "ID=" & Me!ID

Or else use a named argument:

DoCmd.OpenForm "inpProblems", WhereCondition:="ID=" & Me!ID
 
D

Dirk Goldgar

fredg said:
In any event, the Where clause must be placed in the 4th argument
position. You had it in the 3rd position.


Drat! I didn't notice that.
 

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